blog.distrib
Class NegativeBinomial

java.lang.Object
  extended by blog.AbstractCondProbDistrib
      extended by blog.distrib.NegativeBinomial
All Implemented Interfaces:
CondProbDistrib

public class NegativeBinomial
extends AbstractCondProbDistrib

A Negative Binomial distribution with parameters k (number of successes) and p (probability of a success at a given trial). If k is an integer, this is also called the Pascal distribution. The distribution is defined (in discrete terms) as the number of failures before k successes.


Constructor Summary
NegativeBinomial(java.util.List params)
          Creates a new instance of the NegativeBinomial with parameters k and p.
 
Method Summary
 double getLogProb(java.util.List args, java.lang.Object value)
          Returns the log of the probability of n failures in this distribution.
 double getProb(java.util.List args, java.lang.Object value)
          Returns the probability of n failures under this distribution.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Returns a double sampled according to this distribution.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NegativeBinomial

public NegativeBinomial(java.util.List params)
Creates a new instance of the NegativeBinomial with parameters k and p.

Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Returns the probability of n failures under this distribution.


getLogProb

public double getLogProb(java.util.List args,
                         java.lang.Object value)
Returns the log of the probability of n failures in this distribution.

Specified by:
getLogProb in interface CondProbDistrib
Overrides:
getLogProb in class AbstractCondProbDistrib

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Returns a double sampled according to this distribution. Takes time O(GammaDistrib.sampleVal() + Poisson.sampleVal()). (Reference: A Guide To Simulation, 2nd Ed. Bratley, Paul, Bennett L. Fox and Linus E. Schrage.)


toString

public java.lang.String toString()
Overrides:
toString in class AbstractCondProbDistrib