gov.sandia.cognition.statistics.distribution

## Class NegativeBinomialDistribution

• ### Field Summary

Fields
Modifier and Type Field and Description
static double DEFAULT_P
Default p, 0.5.
static double DEFAULT_R
Default r, 1.0.
protected double p
Probability of a positive outcome (Bernoulli probability), [0,1]
protected double r
Number of trials before the experiment is stopped, must be greater than zero.
• ### Method Summary

All Methods
Modifier and Type Method and Description
NegativeBinomialDistribution clone()
This makes public the clone method on the Object class and removes the exception that it throws.
void convertFromVector(Vector parameters)
Converts the object from a Vector of parameters.
Vector convertToVector()
Converts the object to a vector.
NegativeBinomialDistribution.CDF getCDF()
Gets the CDF of a scalar distribution.
IntegerSpan getDomain()
Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution
int getDomainSize()
Gets the size of the domain.
NegativeBinomialDistribution.MaximumLikelihoodEstimator getEstimator()
Gets an estimator associated with this distribution.
java.lang.Integer getMaxSupport()
Gets the minimum support (domain or input) of the distribution.
java.lang.Double getMean()
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
double getMeanAsDouble()
Gets the mean of the distribution as a double.
java.lang.Integer getMinSupport()
Gets the minimum support (domain or input) of the distribution.
double getP()
Getter for p
NegativeBinomialDistribution.PMF getProbabilityFunction()
Gets the distribution function associated with this Distribution, either the PDF or PMF.
double getR()
Getter for r.
double getVariance()
Gets the variance of the distribution.
int sampleAsInt(java.util.Random random)
Draws a single random sample from the distribution as an int.
void sampleInto(java.util.Random random, int[] output, int start, int length)
Samples values from this distribution as an array of ints.
void sampleInto(java.util.Random random, int sampleCount, java.util.Collection<? super java.lang.Number> output)
Draws multiple random samples from the distribution and puts the result into the given collection.
void setP(double p)
Setter for p
void setR(double r)
Setter for r.
java.lang.String toString()
• ### Methods inherited from class gov.sandia.cognition.statistics.AbstractClosedFormIntegerDistribution

sampleAsInts
• ### Methods inherited from class gov.sandia.cognition.statistics.AbstractDistribution

sample, sample
• ### Methods inherited from class java.lang.Object

equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface gov.sandia.cognition.statistics.Distribution

sample, sample
• ### Field Detail

• #### DEFAULT_P

public static final double DEFAULT_P
Default p, 0.5.
Constant Field Values
• #### DEFAULT_R

public static final double DEFAULT_R
Default r, 1.0.
Constant Field Values
• #### r

protected double r
Number of trials before the experiment is stopped, must be greater than zero.
• #### p

protected double p
Probability of a positive outcome (Bernoulli probability), [0,1]
• ### Constructor Detail

• #### NegativeBinomialDistribution

public NegativeBinomialDistribution()
Creates a new instance of NegativeBinomialDistribution
• #### NegativeBinomialDistribution

public NegativeBinomialDistribution(double r,
double p)
Creates a new instance of NegativeBinomialDistribution
Parameters:
r - Number of trials before the experiment is stopped, must be greater than zero.
p - Probability of a positive outcome (Bernoulli probability), [0,1]
• #### NegativeBinomialDistribution

public NegativeBinomialDistribution(NegativeBinomialDistribution other)
Copy constructor
Parameters:
other - NegativeBinomialDistribution to copy
• ### Method Detail

• #### clone

public NegativeBinomialDistribution clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.
Specified by:
clone in interface Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractClosedFormUnivariateDistribution<java.lang.Number>
Returns:
A clone of this object.
• #### getP

public double getP()
Getter for p
Returns:
Probability of a positive outcome (Bernoulli probability), [0,1]
• #### setP

public void setP(double p)
Setter for p
Parameters:
p - Probability of a positive outcome (Bernoulli probability), [0,1]
• #### getR

public double getR()
Getter for r.
Returns:
Number of trials before the experiment is stopped, must be greater than zero.
• #### setR

public void setR(double r)
Setter for r.
Parameters:
r - Number of trials before the experiment is stopped, must be greater than zero.
• #### getMean

public java.lang.Double getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
Specified by:
getMean in interface DistributionWithMean<java.lang.Number>
Returns:
Mean of the distribution.
• #### getMeanAsDouble

public double getMeanAsDouble()
Description copied from interface: UnivariateDistribution
Gets the mean of the distribution as a double.
Specified by:
getMeanAsDouble in interface UnivariateDistribution<java.lang.Number>
Returns:
The mean as a double.
• #### sampleInto

public void sampleInto(java.util.Random random,
int sampleCount,
java.util.Collection<? super java.lang.Number> output)
Description copied from interface: Distribution
Draws multiple random samples from the distribution and puts the result into the given collection.
Specified by:
sampleInto in interface Distribution<java.lang.Number>
Parameters:
random - Random number generator to use.
sampleCount - The number of samples to draw. Cannot be negative.
output - The collection to add the samples into.
• #### sampleAsInt

public int sampleAsInt(java.util.Random random)
Description copied from interface: IntegerDistribution
Draws a single random sample from the distribution as an int.
Specified by:
sampleAsInt in interface IntegerDistribution
Parameters:
random - The random number generator to use.
Returns:
A sample from the distribution.
• #### sampleInto

public void sampleInto(java.util.Random random,
int[] output,
int start,
int length)
Description copied from interface: IntegerDistribution
Samples values from this distribution as an array of ints. This is a convenience method to potentially avoid boxing.
Specified by:
sampleInto in interface IntegerDistribution
Overrides:
sampleInto in class AbstractClosedFormIntegerDistribution
Parameters:
random - Random number generator to use.
output - The array to write the result into. Cannot be null.
start - The offset in the array to start writing at. Cannot be negative.
length - The number of values to sample. Cannot be negative.
• #### convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.
Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.
• #### convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.
Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.
• #### getMinSupport

public java.lang.Integer getMinSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.
Specified by:
getMinSupport in interface UnivariateDistribution<java.lang.Number>
Returns:
Minimum support.
• #### getMaxSupport

public java.lang.Integer getMaxSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.
Specified by:
getMaxSupport in interface UnivariateDistribution<java.lang.Number>
Returns:
Minimum support.
• #### getVariance

public double getVariance()
Description copied from interface: UnivariateDistribution
Gets the variance of the distribution. This is sometimes called the second central moment by more pedantic people, which is equivalent to the square of the standard deviation.
Specified by:
getVariance in interface UnivariateDistribution<java.lang.Number>
Returns:
Variance of the distribution.
• #### getDomain

public IntegerSpan getDomain()
Description copied from interface: DiscreteDistribution
Returns an object that allows an iteration through the domain (x-axis, independent variable) of the Distribution
Specified by:
getDomain in interface DiscreteDistribution<java.lang.Number>
Returns:
Collection that enumerates each value that the domain can take
• #### getDomainSize

public int getDomainSize()
Description copied from interface: DiscreteDistribution
Gets the size of the domain.
Specified by:
getDomainSize in interface DiscreteDistribution<java.lang.Number>
Returns:
The size of the domain.
• #### toString

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