RANDF Generate F-Distributed Random Variable

Section: Random Number Generation

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:

The PDF is given by

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 5
 1.194351196  0.906920850  0.755768538  1.502930284  0.062067628  
 
Columns 6 to 9
 1.386031985  1.816088676  0.375541776  3.579419374  
--> randchi(5*ones(1,9))./randchi(7*ones(1,9))
ans = 
  <float>  - size: [1 9]
 
Columns 1 to 6
 1.3084840  1.2693102  1.0684280  0.4377135  1.1158004  0.7171145  
 
Columns 7 to 9
 0.4150873  1.8022333  1.4605886