File: random_randgamma.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 (69 lines) | stat: -rw-r--r-- 1,867 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
69
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>RANDGAMMA Generate Gamma-Distributed Random Variable
</TITLE>
</HEAD>
<BODY>
<H2>RANDGAMMA Generate Gamma-Distributed Random Variable
</H2>
<P>
Section: <A HREF=sec_random.html> Random Number Generation </A>
<H3>Usage</H3>
Generates random variables with a gamma distribution.  The general
syntax for its use is
<PRE>
   y = randgamma(a,r),
</PRE>
<P>
where <code>a</code> and <code>r</code> are vectors describing the parameters of the
gamma distribution.  Roughly speaking, if <code>a</code> is the mean time between
changes of a Poisson random process, and we wait for the <code>r</code> change,
the resulting wait time is Gamma distributed with parameters <code>a</code> 
and <code>r</code>.
<H3>Function Internals</H3>
The Gamma distribution arises in Poisson random processes.  It represents
the waiting time to the occurance of the <code>r</code>-th event in a process with
mean time <code>a</code> between events.  The probability distribution of a Gamma
random variable is
<P>
<DIV ALIGN="CENTER">
<IMG SRC="randgamma_eqn1.png">
</DIV>
<P>
Note also that for integer values of <code>r</code> that a Gamma random variable
is effectively the sum of <code>r</code> exponential random variables with parameter
<code>a</code>.
<H3>Example</H3>
Here we use the <code>randgamma</code> function to generate Gamma-distributed
random variables, and then generate them again using the <code>randexp</code>
function.
<PRE>
--&gt; randgamma(1,15*ones(1,9))

ans = 

 Columns 1 to 8

   22.7804   11.5514   16.8537   12.7457   16.2303   10.7442   19.3942   16.3611 

 Columns 9 to 9

   17.4772 

--&gt; sum(randexp(ones(15,9)))

ans = 

 Columns 1 to 8

   14.6404   15.1860   13.3147   11.4380    7.2307   10.8225   14.5271   12.4631 

 Columns 9 to 9

   11.8753 
</PRE>
<P>
</BODY>
</HTML>