public class GammaDistribution extends Object implements Distribution
Modifier and Type | Field and Description |
---|---|
private double |
k
Alpha == k
|
(package private) static double[] |
LANCZOS
LANCZOS-Coefficients for Gamma approximation.
|
(package private) static double |
NUM_PRECISION
Numerical precision to use
|
private Random |
random
The random generator.
|
private double |
theta
Theta == 1 / Beta
|
Constructor and Description |
---|
GammaDistribution(double k,
double theta)
Constructor for Gamma distribution.
|
GammaDistribution(double k,
double theta,
Random random)
Constructor for Gamma distribution.
|
Modifier and Type | Method and Description |
---|---|
double |
cdf(double val)
Return the cumulative density function at the given value.
|
static double |
cdf(double val,
double k,
double theta)
The CDF, static version.
|
double |
getK() |
double |
getTheta() |
static double |
logGamma(double x)
Compute logGamma.
|
double |
nextRandom()
Generate a new random value
|
static double |
nextRandom(double k,
double theta,
Random random)
Generate a random value with the generators parameters.
|
double |
pdf(double val)
Return the density of an existing value
|
static double |
pdf(double x,
double k,
double theta)
Gamma distribution PDF (with 0.0 for x < 0)
|
static double |
regularizedGammaP(double a,
double x)
Returns the regularized gamma function P(a, x).
|
static double |
regularizedGammaQ(double a,
double x)
Returns the regularized gamma function Q(a, x) = 1 - P(a, x).
|
String |
toString()
Simple toString explaining the distribution parameters.
|
static final double[] LANCZOS
static final double NUM_PRECISION
private final double k
private final double theta
private Random random
public GammaDistribution(double k, double theta, Random random)
k
- k, alpha aka. "shape" parametertheta
- Theta = 1.0/Beta aka. "scaling" parameterrandom
- Random generatorpublic GammaDistribution(double k, double theta)
k
- k, alpha aka. "shape" parametertheta
- Theta = 1.0/Beta aka. "scaling" parameterpublic double pdf(double val)
Distribution
pdf
in interface Distribution
val
- existing valuepublic double cdf(double val)
Distribution
cdf
in interface Distribution
val
- existing valuepublic double nextRandom()
Distribution
nextRandom
in interface Distribution
public String toString()
toString
in interface Distribution
toString
in class Object
public double getK()
public double getTheta()
public static double cdf(double val, double k, double theta)
val
- Valuek
- Shape ktheta
- Theta = 1.0/Beta aka. "scaling" parameterpublic static double pdf(double x, double k, double theta)
x
- query valuek
- Alphatheta
- Theta = 1 / Betapublic static double logGamma(double x)
x
- Parameter xpublic static double regularizedGammaP(double a, double x)
a
- Parameter ax
- Parameter xpublic static double regularizedGammaQ(double a, double x)
a
- parameter ax
- parameter xpublic static double nextRandom(double k, double theta, Random random)
k
- K parametertheta
- Theta parameterrandom
- Random generator