|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.cmu.minorthird.classify.algorithms.random.Gamma
public class Gamma
Gamma distribution; math definition, definition of gamma function and animated definition.
p(x) = k * x^(alpha-1) * e^(-x/beta) with k = 1/(g(alpha) * b^a)) and g(a) being the gamma function.
Valid parameter ranges: alpha > 0.
Note: For a Gamma distribution to have the mean mean and variance variance, set the parameters as follows:
alpha = mean*mean / variance; lambda = 1 / (variance / mean);
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
Implementation:
J.H. Ahrens, U. Dieter (1974): Computer methods for sampling from gamma, beta, Poisson and binomial distributions, Computing 12, 223-246.
and
J.H. Ahrens, U. Dieter (1982): Generating gamma variates by a modified rejection technique, Communications of the ACM 25, 47-54.
Field Summary | |
---|---|
protected double |
alpha
|
protected RandomElement |
gen
|
protected double |
lambda
|
Constructor Summary | |
---|---|
Gamma(double alpha,
double lambda)
Constructs a Gamma distribution. |
Method Summary | |
---|---|
double |
nextDouble()
Returns a random number from the distribution. |
double |
nextDouble(double alpha,
double lambda)
Returns a random number from the distribution; bypasses the internal state. |
void |
setState(double alpha,
double lambda)
Sets the mean and variance. |
java.lang.String |
toString()
Returns a String representation of the receiver. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected RandomElement gen
protected double alpha
protected double lambda
Constructor Detail |
---|
public Gamma(double alpha, double lambda)
java.lang.IllegalArgumentException
- if alpha <= 0.0 || lambda <= 0.0.Method Detail |
---|
public double nextDouble()
public double nextDouble(double alpha, double lambda)
public void setState(double alpha, double lambda)
java.lang.IllegalArgumentException
- if alpha <= 0.0 || lambda <= 0.0.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |