Tabnine Logo
NegativeBinomial
Code IndexAdd Tabnine to your IDE (free)

How to use
NegativeBinomial
in
cern.jet.random.tdouble

Best Java code snippets using cern.jet.random.tdouble.NegativeBinomial (Showing top 10 results out of 315)

origin: net.sourceforge.parallelcolt/parallelcolt

/**
 * Returns a random number from the distribution with the given parameters n
 * and p.
 * 
 * @param n
 *            the number of trials
 * @param p
 *            the probability of success.
 */
public static int staticNextInt(int n, double p) {
  synchronized (shared) {
    return shared.nextInt(n, p);
  }
}
origin: net.sourceforge.parallelcolt/parallelcolt

  /**
   * Sets the uniform random number generated shared by all <b>static</b>
   * methods.
   * 
   * @param randomGenerator
   *            the new uniform random number generator to be shared.
   */
  private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) {
    synchronized (shared) {
      shared.setRandomGenerator(randomGenerator);
    }
  }
}
origin: net.sourceforge.parallelcolt/parallelcolt

/**
 * Constructs a Negative Binomial distribution. Example: n=1, p=0.5.
 * 
 * @param n
 *            the number of trials.
 * @param p
 *            the probability of success.
 * @param randomGenerator
 *            a uniform random number generator.
 */
public NegativeBinomial(int n, double p, DoubleRandomEngine randomGenerator) {
  setRandomGenerator(randomGenerator);
  setNandP(n, p);
  this.gamma = new Gamma(n, 1.0, randomGenerator);
  this.poisson = new Poisson(0.0, randomGenerator);
}
origin: rwl/ParallelColt

/**
 * Returns a deep copy of the receiver; the copy will produce identical
 * sequences. After this call has returned, the copy and the receiver have
 * equal but separate state.
 * 
 * @return a copy of the receiver.
 */
public Object clone() {
  NegativeBinomial copy = (NegativeBinomial) super.clone();
  if (this.poisson != null)
    copy.poisson = (Poisson) this.poisson.clone();
  copy.poisson.setRandomGenerator(copy.getRandomGenerator());
  if (this.gamma != null)
    copy.gamma = (Gamma) this.gamma.clone();
  copy.gamma.setRandomGenerator(copy.getRandomGenerator());
  return copy;
}
origin: rwl/ParallelColt

/**
 * Constructs a Negative Binomial distribution. Example: n=1, p=0.5.
 * 
 * @param n
 *            the number of trials.
 * @param p
 *            the probability of success.
 * @param randomGenerator
 *            a uniform random number generator.
 */
public NegativeBinomial(int n, double p, DoubleRandomEngine randomGenerator) {
  setRandomGenerator(randomGenerator);
  setNandP(n, p);
  this.gamma = new Gamma(n, 1.0, randomGenerator);
  this.poisson = new Poisson(0.0, randomGenerator);
}
origin: net.sourceforge.parallelcolt/parallelcolt

/**
 * Returns a deep copy of the receiver; the copy will produce identical
 * sequences. After this call has returned, the copy and the receiver have
 * equal but separate state.
 * 
 * @return a copy of the receiver.
 */
public Object clone() {
  NegativeBinomial copy = (NegativeBinomial) super.clone();
  if (this.poisson != null)
    copy.poisson = (Poisson) this.poisson.clone();
  copy.poisson.setRandomGenerator(copy.getRandomGenerator());
  if (this.gamma != null)
    copy.gamma = (Gamma) this.gamma.clone();
  copy.gamma.setRandomGenerator(copy.getRandomGenerator());
  return copy;
}
origin: rwl/ParallelColt

/**
 * Returns a random number from the distribution with the given parameters n
 * and p.
 * 
 * @param n
 *            the number of trials
 * @param p
 *            the probability of success.
 */
public static int staticNextInt(int n, double p) {
  synchronized (shared) {
    return shared.nextInt(n, p);
  }
}
origin: rwl/ParallelColt

  /**
   * Sets the uniform random number generated shared by all <b>static</b>
   * methods.
   * 
   * @param randomGenerator
   *            the new uniform random number generator to be shared.
   */
  private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) {
    synchronized (shared) {
      shared.setRandomGenerator(randomGenerator);
    }
  }
}
origin: rwl/ParallelColt

/**
 * Returns a random number from the distribution; bypasses the internal
 * state.
 */
public int nextInt(int n, double p) {
  /***********************************************************************
   * * Negative Binomial Distribution - Compound method * *
   * ***************************************************************** *
   * FUNCTION: - nbp samples a random number from the Negative * Binomial
   * distribution with parameters r (no. of * failures given) and p
   * (probability of success) * valid for r > 0, 0 < p < 1. * If G from
   * Gamma(r) then K from Poiss(pG/(1-p)) * is NB(r,p)--distributed. *
   * REFERENCE: - J.H. Ahrens, U. Dieter (1974): Computer methods * for
   * sampling from gamma, beta, Poisson and * binomial distributions,
   * Computing 12, 223--246. * SUBPROGRAMS: - drand(seed) ...
   * (0,1)-Uniform generator with * unsigned long integer *seed * -
   * Gamma(seed,a) ... Gamma generator for a > 0 * unsigned long *seed,
   * double a * - Poisson(seed,a) ...Poisson generator for a > 0 *
   * unsigned long *seed, double a. * *
   **********************************************************************/
  double x = p / (1.0 - p);
  double p1 = p;
  double y = x * this.gamma.nextDouble(n, 1.0);
  return this.poisson.nextInt(y);
}
origin: net.sourceforge.parallelcolt/parallelcolt

/**
 * Returns a random number from the distribution; bypasses the internal
 * state.
 */
public int nextInt(int n, double p) {
  /***********************************************************************
   * * Negative Binomial Distribution - Compound method * *
   * ***************************************************************** *
   * FUNCTION: - nbp samples a random number from the Negative * Binomial
   * distribution with parameters r (no. of * failures given) and p
   * (probability of success) * valid for r > 0, 0 < p < 1. * If G from
   * Gamma(r) then K from Poiss(pG/(1-p)) * is NB(r,p)--distributed. *
   * REFERENCE: - J.H. Ahrens, U. Dieter (1974): Computer methods * for
   * sampling from gamma, beta, Poisson and * binomial distributions,
   * Computing 12, 223--246. * SUBPROGRAMS: - drand(seed) ...
   * (0,1)-Uniform generator with * unsigned long integer *seed * -
   * Gamma(seed,a) ... Gamma generator for a > 0 * unsigned long *seed,
   * double a * - Poisson(seed,a) ...Poisson generator for a > 0 *
   * unsigned long *seed, double a. * *
   **********************************************************************/
  double x = p / (1.0 - p);
  double p1 = p;
  double y = x * this.gamma.nextDouble(n, 1.0);
  return this.poisson.nextInt(y);
}
cern.jet.random.tdoubleNegativeBinomial

Javadoc

Negative Binomial distribution; See the math definition.

Instance methods operate on a user supplied uniform random number generator; they are unsynchronized. Static methods operate on a default uniform random number generator; they are synchronized.

Implementation: High performance implementation. Compound method. This is a port of nbp.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon

J.H. Ahrens, U. Dieter (1974): Computer methods for sampling from gamma, beta, Poisson and binomial distributions, Computing 12, 223--246.

Most used methods

  • getRandomGenerator
  • nextInt
  • setNandP
    Sets the parameters number of trials and the probability of success.
  • setRandomGenerator

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • findViewById (Activity)
  • getSystemService (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now