## org.apache.mahout.math.jet.random
Class Gamma

    java.lang.Object
      org.apache.mahout.math.function.DoubleFunction
          org.apache.mahout.math.jet.random.AbstractDistribution
              org.apache.mahout.math.jet.random.AbstractContinousDistribution
                  org.apache.mahout.math.jet.random.Gamma

All Implemented Interfaces:
  IntFunction

    public class Gamma

extends AbstractContinousDistribution

Constructor Summary
`Gamma(double alpha, double rate, 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.
`static double` `logGamma(double x)` Returns a quick approximation of `log(gamma(x))`.
`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.
`String` `toString()`

Methods inherited from class org.apache.mahout.math.jet.random.AbstractContinousDistribution
`nextInt`

Methods inherited from class org.apache.mahout.math.jet.random.AbstractDistribution
`apply, apply, getRandomGenerator, randomDouble, setRandomGenerator`

Methods inherited from class org.apache.mahout.math.function.DoubleFunction
`isDensifying`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Gamma

    public Gamma(double alpha,
                 double rate,
                 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:
    `IllegalArgumentException` - if `alpha <= 0.0 || alpha <= 0.0`.

Method Detail

### 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 String toString()

  Overrides:
    `toString` in class `Object`

### logGamma

    public static double logGamma(double x)

  Returns a quick approximation of `log(gamma(x))`.

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.