File: random_randf.html

package info (click to toggle)
freemat 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 174,756 kB
  • ctags: 67,023
  • sloc: cpp: 351,059; ansic: 255,892; sh: 40,590; makefile: 4,387; perl: 4,058; asm: 3,313; pascal: 2,718; fortran: 1,722; ada: 1,681; ml: 1,360; cs: 879; csh: 795; python: 430; sed: 162; lisp: 160; awk: 5
file content (68 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>RANDF Generate F-Distributed Random Variable
</TITLE>
</HEAD>
<BODY>
<H2>RANDF Generate F-Distributed Random Variable
</H2>
<P>
Section: <A HREF=sec_random.html> Random Number Generation </A>
<H3>Usage</H3>
Generates random variables with an F-distribution.  The general
syntax for its use is
<PRE>
   y = randf(n,m)
</PRE>
<P>
where <code>n</code> and <code>m</code> 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.
<H3>Function Internals</H3>
The statistic <code>F_{n,m}</code> is defined as the ratio of two chi-square
random variables:
<P>
<DIV ALIGN="CENTER">
<IMG SRC="randf_eqn1.png">
</DIV>
<P>
The PDF is given by
<P>
<DIV ALIGN="CENTER">
<IMG SRC="randf_eqn2.png">
</DIV>
<P>
where <code>B(a,b)</code> is the beta function.
<H3>Example</H3>
Here we use <code>randf</code> to generate some F-distributed random variables,
and then again using the <code>randchi</code> function:
<PRE>
--&gt; randf(5*ones(1,9),7)

ans = 

 Columns 1 to 8

    1.1944    0.9069    0.7558    1.5029    0.0621    1.3860    1.8161    0.3755 

 Columns 9 to 9

    3.5794 

--&gt; randchi(5*ones(1,9))./randchi(7*ones(1,9))

ans = 

 Columns 1 to 8

    1.3085    1.2693    1.0684    0.4377    1.1158    0.7171    0.4151    1.8022 

 Columns 9 to 9

    1.4606 
</PRE>
<P>
</BODY>
</HTML>