Home > wafo > wstats > wfrnd.m

wfrnd

PURPOSE ^

Random matrices from the Snedecor's F distribution

SYNOPSIS ^

R = wfrnd(a,b,varargin)

DESCRIPTION ^

 WFRND Random matrices from the Snedecor's F distribution
 
  CALL:  R = wfrnd(df1,df2,sz);
 
         R = matrix of random numbers
  df1,df2, = degrees of freedom
        sz = size(R)    (Default size(b))
             sz can be a comma separated list or a vector 
             giving the size of R (see zeros for options)
 
  The random numbers are generated by the inverse method. 
  
  Example:
    R=wfrnd(1,1,100,1);
    plot(R,'.')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function R = wfrnd(a,b,varargin)
002 %WFRND Random matrices from the Snedecor's F distribution
003 %
004 % CALL:  R = wfrnd(df1,df2,sz);
005 %
006 %        R = matrix of random numbers
007 % df1,df2, = degrees of freedom
008 %       sz = size(R)    (Default size(b))
009 %            sz can be a comma separated list or a vector 
010 %            giving the size of R (see zeros for options)
011 %
012 % The random numbers are generated by the inverse method. 
013 % 
014 % Example:
015 %   R=wfrnd(1,1,100,1);
016 %   plot(R,'.')
017   
018 % tested on matlab 5.3
019 %History:
020 %revised pab 29.10.2000
021 % adapted from stixbox
022 % -added nargchk, comnsize + check that df1, df2 are positive integers
023 %        Anders Holtsberg, 18-11-93
024 %        Copyright (c) Anders Holtsberg
025 
026 error(nargchk(2,inf,nargin))
027 if nargin<3,
028   [errorcode a b] = comnsize(a,b);
029 else
030   [errorcode a b] = comnsize(a,b,zeros(varargin{:}));
031 end 
032 if errorcode > 0
033   error('df1 and df2 must be a scalar or of corresponding size as given by m and n.');
034 end
035 
036 
037 R = zeros(size(a));
038 
039 ok = (a>0 & b>0 & floor(a)==a & floor(b)==b);
040 
041 k = find( ok);
042 if any(k)
043   x = wbetarnd(a(k)/2,b(k)/2);
044   R(k) = x.*b(k)./((1-x).*a(k));
045 end
046 
047 
048 k3=find(~ok);
049 if any(k3)
050   tmp=NaN;
051   x(k3)=tmp(ones(size(k3)));
052 end
053

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