public class GammaDistribution extends Object
References:
(c) Apache Software Foundation (ASF), Apache commons math project
Constructor and Description |
---|
GammaDistribution(double alpha,
double beta)
Create a new gamma distribution with the given
alpha and
beta values. |
Modifier and Type | Method and Description |
---|---|
double |
getAlpha()
Access the
alpha shape parameter. |
double |
getBeta()
Access the
beta scale parameter. |
double |
nextGamma(double shape,
double scale)
Generates a random value from the Gamma Distribution.
|
double |
sample()
Generate a random value sampled from this distribution.
|
public GammaDistribution(double alpha, double beta)
alpha
and
beta
values.alpha
- Shape parameter.beta
- Scale parameter.IllegalArgumentException
- if alpha <= 0
or
beta <= 0
.public double getAlpha()
alpha
shape parameter.alpha
.public double getBeta()
beta
scale parameter.beta
.public double sample()
public double nextGamma(double shape, double scale)
Generates a random value from the Gamma Distribution.
This implementation uses the following algorithms:
For 0 < shape < 1:
Ahrens, J. H. and Dieter, U., Computer methods for
sampling from gamma, beta, Poisson and binomial distributions.
Computing, 12, 223-246, 1974.
For shape >= 1:
Marsaglia and Tsang, A Simple Method for Generating
Gamma Variables. ACM Transactions on Mathematical Software,
Volume 26 Issue 3, September, 2000.
shape
- the median of the Gamma distributionscale
- the scale parameter of the Gamma distributionCopyright © 2012 Thomas Hillebrandt. All Rights Reserved.