Return a matrix with gamma (a,1)
distributed random elements.
The arguments are handled the same as the arguments for rand
, except
for the argument a.
This can be used to generate many distributions:
gamma (a, b)
for a > -1
, b > 0
r = b * randg (a)
beta (a, b)
for a > -1
, b > -1
r1 = randg (a, 1) r = r1 / (r1 + randg (b, 1))
Erlang (a, n)
r = a * randg (n)
chisq (df)
for df > 0
r = 2 * randg (df / 2)
t (df)
for 0 < df < inf
(use randn if df is infinite)r = randn () / sqrt (2 * randg (df / 2) / df)
F (n1, n2)
for 0 < n1
, 0 < n2
## r1 equals 1 if n1 is infinite r1 = 2 * randg (n1 / 2) / n1 ## r2 equals 1 if n2 is infinite r2 = 2 * randg (n2 / 2) / n2 r = r1 / r2
binomial (n, p)
for n > 0
, 0 < p <= 1
r = randp ((1 - p) / p * randg (n))
chisq (df, L)
, for df >= 0
and L > 0
(use chisq if L = 0
)
r = randp (L / 2) r(r > 0) = 2 * randg (r(r > 0)) r(df > 0) += 2 * randg (df(df > 0)/2)
Dirichlet (a1, … ak)
r = (randg (a1), …, randg (ak)) r = r / sum (r)
The class of the value returned can be controlled by a trailing
"double"
or "single"
argument. These are the only valid
classes.
See also: rand, randn, rande, randp.
Package: octave