next up previous contents
Next: RANDGAMMA Generate Gamma-Distributed Random Up: Random Number Generation Previous: RANDNBIN Generate Negative Binomial   Contents

Subsections

RANDF Generate F-Distributed Random Variable

Usage

Generates random variables with an F-distribution. The general syntax for its use is

   y = randf(n,m)

where n and m are vectors of the number of degrees of freedom in the numerator and denominator of the chi-square random variables whose ratio defines the statistic.

Function Internals

The statistic F_{n,m} is defined as the ratio of two chi-square random variables:

$\displaystyle F_{n,m} = \frac{\chi_n^2/n}{\chi_m^2/m}
$

The PDF is given by

$\displaystyle f_{n,m} = \frac{m^{m/2}n^{n/2}x^{n/2-1}}{(m+nx)^{(n+m)/2}B(n/2,m/2)},
$

where B(a,b) is the beta function.

Example

Here we use randf to generate some F-distributed random variables, and then again using the randchi function:

--> randf(5*ones(1,9),7)
ans = 
  <float>  - size: [1 9]
 
Columns 1 to 3
    1.0182518          1.6145548          1.2731971       
 
Columns 4 to 6
    0.99473107         0.21895742         3.7101061       
 
Columns 7 to 9
    1.1556993          0.78403413         2.9067836       
--> randchi(5*ones(1,9))./randchi(7*ones(1,9))
ans = 
  <float>  - size: [1 9]
 
Columns 1 to 3
    2.5839260          0.59389555         0.25209698      
 
Columns 4 to 6
    0.99553269         0.69540071         2.1197720       
 
Columns 7 to 9
    0.85026217         0.39067981         0.34328517



Samit K. Basu 2005-03-16