Generates random variables with a gamma distribution. The general syntax for its use is
y = randgamma(a,r),
where a
and r
are vectors describing the parameters of the
gamma distribution. Roughly speaking, if a
is the mean time between
changes of a Poisson random process, and we wait for the r
change,
the resulting wait time is Gamma distributed with parameters a
and r
.
The Gamma distribution arises in Poisson random processes. It represents
the waiting time to the occurance of the r
-th event in a process with
mean time a
between events. The probability distribution of a Gamma
random variable is
Note also that for integer values of
r
that a Gamma random variable
is effectively the sum of r
exponential random variables with parameter
a
.
Here we use the randgamma
function to generate Gamma-distributed
random variables, and then generate them again using the randexp
function.
--> randgamma(1,15*ones(1,9)) ans = <float> - size: [1 9] Columns 1 to 3 18.003479 18.014494 22.860670 Columns 4 to 6 18.482702 15.879181 14.020444 Columns 7 to 9 18.032330 18.265949 10.394668 --> sum(randexp(ones(15,9))) ans = <float> - size: [1 9] Columns 1 to 3 21.299023 18.793451 16.707335 Columns 4 to 6 16.798256 14.229127 14.662329 Columns 7 to 9 16.892017 18.660885 8.9591293