Home > wafo > wstats > wraylstat.m

# wraylstat

## PURPOSE

Mean and variance for the Rayleigh distribution.

## SYNOPSIS

[m,v]= wraylstat(b);

## DESCRIPTION

``` WRAYLSTAT Mean and variance for the Rayleigh distribution.

CALL:  [m,v] = wraylstat(b)

m, v = the mean and variance, respectively
b = parameter of the Rayleigh distribution (see wraylcdf)

Mean (m) and variance (v) for the Rayleigh distribution is

m=b*(pi/2)^(1/2)  and  v=(2-pi/2)*b^2;

Example:
[m,v] = wraylstat(1/(pi/2)^(1/2))

## CROSS-REFERENCE INFORMATION

This function calls:
 error Display message and abort function. nan Not-a-Number.
This function is called by:
 dist2dcdf Joint 2D CDF computed as int F(X1 dist2dstat Mean and variance for the DIST2D distribution mdist2dstat Mean and variance for the MDIST2D distribution.

## SOURCE CODE

```001 function [m,v]= wraylstat(b);
002 %WRAYLSTAT Mean and variance for the Rayleigh distribution.
003 %
004 % CALL:  [m,v] = wraylstat(b)
005 %
006 %   m, v = the mean and variance, respectively
007 %      b = parameter of the Rayleigh distribution (see wraylcdf)
008 %
009 %  Mean (m) and variance (v) for the Rayleigh distribution is
010 %
011 %  m=b*(pi/2)^(1/2)  and  v=(2-pi/2)*b^2;
012 %
013 % Example:
014 %   [m,v] = wraylstat(1/(pi/2)^(1/2))
015 %
017
018 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
019 % and Life Span Models", p. 181 ff, Marcel Dekker.
020
021 %tested on: matlab 5.3
022 % history
023 % revised pab 24.10.2000
024 % Added checks on b
025
026
027
028 error(nargchk(1,1,nargin))
029
030 %   Initialize Mean and Variance to zero.
031 m = zeros(size(b));
032 v = zeros(size(b));
033
034 ok = (b > 0);
035 k = find(ok);
036 if any(k)
037  m(k) = b(k) * sqrt(pi/2);
038  v(k) = (2 - pi/2) * b(k) .^ 2;
039 end
040
041 k1 = find(~ok);
042 if any(k1)
043     tmp = NaN;
044     m(k1) = tmp(ones(size(k1)));
045     v(k1) = m(k1);
046 end
047
048
049
050
051
052```

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