org.apache.mahout.math.jet.random
Class Gamma
java.lang.Object
org.apache.mahout.math.PersistentObject
org.apache.mahout.math.jet.random.AbstractDistribution
org.apache.mahout.math.jet.random.AbstractContinousDistribution
org.apache.mahout.math.jet.random.Gamma
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, org.apache.mahout.math.function.DoubleFunction, IntFunction, UnaryFunction
public class Gamma
- extends AbstractContinousDistribution
- See Also:
- Serialized Form
Constructor Summary |
Gamma(double alpha,
double rate,
java.util.Random randomGenerator)
Constructs a Gamma distribution with a given shape (alpha) and rate (beta). |
Method Summary |
double |
cdf(double x)
Returns the cumulative distribution function. |
double |
nextDouble()
Returns a random number from the distribution. |
double |
nextDouble(double alpha,
double rate)
Returns a random number from the distribution; bypasses the internal state. |
double |
pdf(double x)
Returns the probability distribution function. |
java.lang.String |
toString()
|
Methods inherited from class org.apache.mahout.math.PersistentObject |
clone |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Gamma
public Gamma(double alpha,
double rate,
java.util.Random randomGenerator)
- Constructs a Gamma distribution with a given shape (alpha) and rate (beta).
- Parameters:
alpha
- The shape parameter.rate
- The rate parameter.randomGenerator
- The random number generator that generates bits for us.
- Throws:
java.lang.IllegalArgumentException
- if alpha <= 0.0 || alpha <= 0.0.
cdf
public double cdf(double x)
- Returns the cumulative distribution function.
- Overrides:
cdf
in class AbstractContinousDistribution
- Parameters:
x
- The end-point where the cumulation should end.
nextDouble
public double nextDouble()
- Returns a random number from the distribution.
- Specified by:
nextDouble
in class AbstractDistribution
- Returns:
- A new sample from this distribution.
nextDouble
public double nextDouble(double alpha,
double rate)
- Returns a random number from the distribution; bypasses the internal state.
*
Gamma Distribution - Acceptance Rejection combined with *
Acceptance Complement *
*
*
FUNCTION: - gds samples a random number from the standard *
gamma distribution with parameter a > 0. *
Acceptance Rejection gs for a < 1 , *
Acceptance Complement gd for a >= 1 . *
REFERENCES: - J.H. Ahrens, U. Dieter (1974): Computer methods *
for sampling from gamma, beta, Poisson and *
binomial distributions, Computing 12, 223-246. *
- J.H. Ahrens, U. Dieter (1982): Generating gamma *
variates by a modified rejection technique, *
Communications of the ACM 25, 47-54. *
SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform generator with *
unsigned long integer *seed *
- NORMAL(seed) ... Normal generator N(0,1). *
*
- Parameters:
alpha
- Shape parameter.rate
- Rate parameter (=1/scale).
- Returns:
- A gamma distributed sample.
pdf
public double pdf(double x)
- Returns the probability distribution function.
- Overrides:
pdf
in class AbstractContinousDistribution
- Parameters:
x
- Where to compute the density function.
- Returns:
- The value of the gamma density at x.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.