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

    java.lang.Object
      org.apache.mahout.math.PersistentObject
          org.apache.mahout.math.jet.random.AbstractDistribution
              org.apache.mahout.math.jet.random.AbstractDiscreteDistribution
                  org.apache.mahout.math.jet.random.Binomial

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, org.apache.mahout.math.function.DoubleFunction, IntFunction, UnaryFunction

Deprecated. until unit tests are in place. Until this time, this class/interface is unsupported.

    @Deprecated
    public class Binomial

extends AbstractDiscreteDistribution

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.apache.mahout.math.jet.random.AbstractDistribution
`randomGenerator`

Constructor Summary
`Binomial(int n, double p, java.util.Random randomGenerator)` Deprecated. Constructs a binomial distribution.

Method Summary
`double` `cdf(int k)` Deprecated. Returns the cumulative distribution function.

`protected int`

`generateBinomial(int n, double p)`
Deprecated. *************************************************************** Binomial-Distribution - Acceptance Rejection/Inversion * ***************************************************************** Acceptance Rejection method combined with Inversion for generating Binomial random numbers with parameters * n (number of trials) and p (probability of success).

`int` `nextInt()` Deprecated.
`int` `nextInt(int n, double p)` Deprecated. Returns a random number from the distribution with the given parameters n and p; bypasses the internal state.
`double` `pdf(int k)` Deprecated. Returns the probability distribution function.
`void` `setNandP(int n, double p)` Deprecated. Sets the parameters number of trials and the probability of success.
`static int` `staticNextInt(int n, double p)` Deprecated. Returns a random number from the distribution with the given parameters n and p.
`java.lang.String` `toString()` Deprecated. Returns a String representation of the receiver.

Methods inherited from class org.apache.mahout.math.jet.random.AbstractDiscreteDistribution
`nextDouble`

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

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`

Constructor Detail

### Binomial

    public Binomial(int n,
                    double p,
                    java.util.Random randomGenerator)

  Deprecated.
  Constructs a binomial distribution. Example: n=1, p=0.5.

  Parameters:
    `n` - the number of trials (also known as sample size).
    `p` - the probability of success.
    `randomGenerator` - a uniform random number generator.
  Throws:
    `java.lang.IllegalArgumentException` - if `n*Math.min(p,1-p) <= 0.0`

Method Detail

### cdf

    public double cdf(int k)

  Deprecated.
  Returns the cumulative distribution function.

### nextInt

    public int nextInt()

  Deprecated.
  Specified by:
    `nextInt` in class `AbstractDiscreteDistribution`
  Returns:
    A random number from the distribution; returns `(int) Math.round(nextDouble())`. Override this method if necessary.

### generateBinomial

    protected int generateBinomial(int n,
                                   double p)

  Deprecated.
  *************************************************************** Binomial-Distribution - Acceptance Rejection/Inversion * ***************************************************************** Acceptance Rejection method combined with Inversion for generating Binomial random numbers with parameters * n (number of trials) and p (probability of success). For min(n*p,n*(1-p)) < 10 the Inversion method is applied: * The random numbers are generated via sequential search, starting at the lowest index k=0. The cumulative probabilities are avoided by using the technique of chop-down. For min(n*p,n*(1-p)) >= 10 Acceptance Rejection is used: The algorithm is based on a hat-function which is uniform in the centre region and exponential in the tails. A triangular immediate acceptance region in the centre speeds up the generation of binomial variates. If candidate k is near the mode, f(k) is computed recursively * starting at the mode m. The acceptance test by Stirling's formula is modified according to W. Hoermann (1992): The generation of binomial random variates, to appear in J. Statist. Comput. Simul. If p < .5 the algorithm is applied to parameters n, p. Otherwise p is replaced by 1-p, and k is replaced by n - k. ***************************************************************** FUNCTION: - samples a random number from the binomial distribution with parameters n and p and is valid for n*min(p,1-p) > 0. * REFERENCE: - V. Kachitvichyanukul, B.W. Schmeiser (1988): Binomial random variate generation, * Communications of the ACM 31, 216-222. SUBPROGRAMS: - StirlingCorrection() * ... Correction term of the Stirling approximation for log(k!) * (series in 1/k or table values for small k) with long int k * - randomGenerator ... (0,1)-Uniform engine * ****************************************************************

### nextInt

    public int nextInt(int n,
                       double p)

  Deprecated.
  Returns a random number from the distribution with the given parameters n and p; bypasses the internal state.

  Parameters:
    `n` - the number of trials
    `p` - the probability of success.
  Throws:
    `java.lang.IllegalArgumentException` - if `n*Math.min(p,1-p) <= 0.0`

### pdf

    public double pdf(int k)

  Deprecated.
  Returns the probability distribution function.

### setNandP

    public final void setNandP(int n,
                               double p)

  Deprecated.
  Sets the parameters number of trials and the probability of success.

  Parameters:
    `n` - the number of trials
    `p` - the probability of success.
  Throws:
    `java.lang.IllegalArgumentException` - if `n*Math.min(p,1-p) <= 0.0`

### staticNextInt

    public static int staticNextInt(int n,
                                    double p)

  Deprecated.
  Returns a random number from the distribution with the given parameters n and p.

  Parameters:
    `n` - the number of trials
    `p` - the probability of success.
  Throws:
    `java.lang.IllegalArgumentException` - if `n*Math.min(p,1-p) <= 0.0`

### toString

    public java.lang.String toString()

  Deprecated.
  Returns a String representation of the receiver.

  Overrides:
    `toString` in class `java.lang.Object`

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.