F-Distribution random numbers
R = distfun_frnd(v1,v2) R = distfun_frnd(v1,v2,[m,n]) R = distfun_frnd(v1,v2,m,n)
a n-by-m matrix of doubles, numerator degrees of freedom, v1>0 (can be non integer).
a n-by-m matrix of doubles, denominator degrees of freedom, v2>0 (can be non integer).
a 1x1 matrix of floating point integers, the number of rows of R
a 1x1 matrix of floating point integers, the number of columns of R
a matrix of doubles, the random numbers in the set [0,∞).
Generates random variables from the F-distribution function.
Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.
// set the initial seed for tests distfun_seedset(1); // Test with expanded v1 and v2 computed = distfun_frnd(1:6,1:6) expected = [ 2.905302978312094830D-01 1.579862093854028371D-01 1.642623974391084429D+00 6.260081014837054481D-01 4.407037914058102857D-01 2.654717535342397405D-01 ]' // Check R = distfun_frnd(v1,v2,v) computed = size(distfun_frnd(2,5,[3 3])) expected = [3 3] // Check mean and variance N = 5000; v1 = 3; v2 = 5; R = distfun_frnd(v1,v2,[1 N]); RM = mean(R) RV = variance(R) [M,V] = distfun_fstat(v1,v2) // Make a plot of the actual distribution of the numbers v1 = 10; v2 = 50; data = distfun_frnd(v1,v2,1,1000); scf(); histplot(20,data) x = linspace(0,4,1000); y = distfun_fpdf(x,v1,v2); plot(x,y) xtitle("F Random Numbers","X","Density") legend(["Empirical","PDF"]); // Make a plot of a ratio of chi-square random numbers v1 = 10; v2 = 50; R1 = distfun_chi2rnd(v1,1,1000); R2 = distfun_chi2rnd(v2,1,1000); data = (R1./v1)./(R2./v2); scf(); histplot(20,data) x = linspace(0,4,1000); y = distfun_fpdf(x,v1,v2); plot(x,y) xtitle("$\textrm{Random Numbers }\frac{R_1/v_1}{R_2/v_2}$","X","Density") legend(["Empirical","PDF"]); | ![]() | ![]() |
http://en.wikipedia.org/wiki/F-distribution