Home > wafo > wstats > wraylinv.m

# wraylinv

## PURPOSE

Inverse of the Rayleigh distribution function

## SYNOPSIS

x = wraylinv(F,b)

## DESCRIPTION

``` WRAYLINV Inverse of the Rayleigh distribution function

CALL:  x = wraylinv(F,b)

x = inverse cdf for the Rayleigh distribution evaluated at F
b = parameter

The Rayleigh distribution is defined by its cdf

F(x;b) = 1 - exp(-x^2/(2b^2)), x>=0

Example:
F = linspace(0,1,100);
x = wraylinv(F,1);
plot(F,x)```

## CROSS-REFERENCE INFORMATION

This function calls:
 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:
 wraylrnd Random matrices from a Rayleigh distribution

## SOURCE CODE

```001 function x = wraylinv(F,b)
002 %WRAYLINV Inverse of the Rayleigh distribution function
003 %
004 % CALL:  x = wraylinv(F,b)
005 %
006 %        x = inverse cdf for the Rayleigh distribution evaluated at F
007 %        b = parameter
008 %
009 % The Rayleigh distribution is defined by its cdf
010 %
011 %  F(x;b) = 1 - exp(-x^2/(2b^2)), x>=0
012 %
013 %
014 % Example:
015 %   F = linspace(0,1,100);
016 %   x = wraylinv(F,1);
017 %   plot(F,x)
018
019
020 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
021 % and Life Span Models", p. 181 ff, Marcel Dekker.
022
023 % Tested on: Matlab 5.3
024 % History:
025 % revised pab 24.10.2000
026 % - added comnsize, nargchk
028
029
030 error(nargchk(2,2,nargin))
031
032 [errorcode, F, b] = comnsize(F,b);
033 if (errorcode > 0)
034   error ('F and b must be of common size or scalar');
035 end
036
037 x=zeros(size(F));
038
039
040 k = find ((F == 1) & (b>0));
041 if any (k),
042   tmp=inf;
043   x(k) = tmp(ones (size(k)));
044 end
045
046 k1 = find ((F > 0) & (F < 1) & (b>0));
047 if any (k1),
048   x(k1)=sqrt(-2*log(1-F(k1))).*b(k1);
049 end
050
051 k2 = find(F<0 | F>1 | (b<=0));
052 if any(k2),
053   tmp=NaN;
054   x(k2)=tmp(ones(size(k2)));
055 end
056
057
058```

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