Home > wafo > wavemodels > braylcdf.m

# braylcdf

## PURPOSE

Beta Rayleigh CDF of wave heights

## SYNOPSIS

y = braylcdf(x,a,b,c)

## DESCRIPTION

``` BRAYLCDF Beta Rayleigh CDF of wave heights
/h
F = | 2*(a+b-1)!/((a-1)! * (b-1)!)*x^(2a-1)*(1-(x/c)^2)^(b-1)/c^(2a) dx
/0

CALL:  F = braylcdf(h,a,b,c)

F = cdf
h = waveheigth (0 <= h <= c)
a = abs(k1*(k2-k1)/(k1^2-k2))
b = abs(1-k1)*(k2-k1)/(k1^2-k2))
c = Hb, breaking wave height approximated by water depth, d.
where
k1 = E(H^2)/Hb^2
k2 = E(H^4)/Hb^4
E(H^2) = .5*exp(0.00272*(d/g*Tp^2)^(-0.834))*Hm0^2
E(H^4) = .5*exp(0.00046*(d/g*Tp^2)^(-1.208))*Hm0^2
Hm0 = significant waveheight
Tp  = modal period of wave spectrum

The size of F is the common size of H, A, B and C.  A scalar input
functions as a constant matrix of the same size as the other input.

Example: % Compare with rayleigh distribution
Hm0 = 7;Tp = 11;d = 50; g = gravity;
k1  = .5*exp(0.00272*(d/g*Tp^2)^(-0.834))*Hm0^2/d^2;
k2  = .5*exp(0.00046*(d/g*Tp^2)^(-1.208))*Hm0^2/d^4;
a   = abs(k1*(k2-k1)/(k1^2-k2));
b   = abs((1-k1)*(k2-k1)/(k1^2-k2));
h   = linspace(0,2*Hm0)';
semilogy(h,1-braylcdf(h,a,b,d),'r',h,1-wraylcdf(h,Hm0/2))

## CROSS-REFERENCE INFORMATION

This function calls:
 wbetacdf Beta cumulative distribution function comnsize Check if all input arguments are either scalar or of common size. error Display message and abort function. nan Not-a-Number.
This function is called by:

## SOURCE CODE

```001 function y = braylcdf(x,a,b,c)
002 %BRAYLCDF Beta Rayleigh CDF of wave heights
003 %       /h
004 %   F = | 2*(a+b-1)!/((a-1)! * (b-1)!)*x^(2a-1)*(1-(x/c)^2)^(b-1)/c^(2a) dx
005 %       /0
006 %
007 %  CALL:  F = braylcdf(h,a,b,c)
008 %
009 %       F = cdf
010 %       h = waveheigth (0 <= h <= c)
011 %       a = abs(k1*(k2-k1)/(k1^2-k2))
012 %       b = abs(1-k1)*(k2-k1)/(k1^2-k2))
013 %       c = Hb, breaking wave height approximated by water depth, d.
014 % where
015 %      k1 = E(H^2)/Hb^2
016 %      k2 = E(H^4)/Hb^4
017 %  E(H^2) = .5*exp(0.00272*(d/g*Tp^2)^(-0.834))*Hm0^2
018 %  E(H^4) = .5*exp(0.00046*(d/g*Tp^2)^(-1.208))*Hm0^2
019 %     Hm0 = significant waveheight
020 %     Tp  = modal period of wave spectrum
021 %
022 %    The size of F is the common size of H, A, B and C.  A scalar input
023 %    functions as a constant matrix of the same size as the other input.
024 %
025 % Example: % Compare with rayleigh distribution
026 %  Hm0 = 7;Tp = 11;d = 50; g = gravity;
027 %  k1  = .5*exp(0.00272*(d/g*Tp^2)^(-0.834))*Hm0^2/d^2;
028 %  k2  = .5*exp(0.00046*(d/g*Tp^2)^(-1.208))*Hm0^2/d^4;
029 %  a   = abs(k1*(k2-k1)/(k1^2-k2));
030 %  b   = abs((1-k1)*(k2-k1)/(k1^2-k2));
031 %  h   = linspace(0,2*Hm0)';
032 % semilogy(h,1-braylcdf(h,a,b,d),'r',h,1-wraylcdf(h,Hm0/2))
033 %
035
036 %
037 %   Reference:
038 %       Michel K. Ochi (1998),
039 %      "OCEAN WAVES, The stochastic approach",
040 %       OCEAN TECHNOLOGY series 6, Cambridge, pp 279. (pd of peaks to trough)
041
042 % tested on: matlab 5.x
043 % History:
044 % Revised pab 31.03.2001
045 %  added example
046 % revised pab 14.10.1999
047 % updated help header
048 %  Per A. Brodtkorb 21.02.99
049 error(nargchk(4,4,nargin))
050
051
052 [errorcode, x, a, b, c] = comnsize(x,a,b,c);
053 if errorcode > 0
054     error('h, a, b and c must be of common size or scalar.');
055 end
056
057
058 % Initialize Y to zero.
059 y=zeros(size(x));
060
061 % Return NaN if A,B or C  is not positive.
062 k1 = find(a <= 0| b<=0|c<=0);
063 if any(k1)
064     tmp   = NaN;
065     y(k1) = tmp(ones(size(k1)));
066 end
067
068 k=find(a > 0 & x >0 & b>0 & c>0);
069 if any(k),
070   xk = x(k); ak = a(k); bk = b(k);ck=c(k);
071   y(k)=wbetacdf((xk./ck).^2,ak,bk);
072 end
073
074
075
076
077```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003