jhplot.math.num.pdf
Class NegativeBinomial
- java.lang.Object
-
- jhplot.math.num.pdf.DiscreteDistribution
-
- jhplot.math.num.pdf.NegativeBinomial
-
- All Implemented Interfaces:
- Distribution
public class NegativeBinomial extends DiscreteDistribution
The Negative Binomial distribution.
References:
- Eric W. Weisstein. "Negative Binomial Distribution." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/NegativeBinomial.html
- Since:
- 1.2
-
-
Constructor Summary
Constructors Constructor and Description NegativeBinomial()
Default constructor.NegativeBinomial(int r, double p)
Create a distribution with the given number of successes and probability of success.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double
cumulativeProbability(int x)
The CDF for this distribution.double
getMean()
Get mean value.int
getNumberOfSuccesses()
Access the number of successes.double
getProbabilityOfSuccess()
Access probability of success.double
getVariance()
Get mean value.int
inverseCumulativeProbability(double p)
The inverse CDF for this distribution.double
probability(int x)
The PMF for this distribution.void
setNumberOfSuccesses(int r)
Modify the number of successes.void
setProbabilityOfSuccess(double p)
Modify probability of success.
-
-
-
Constructor Detail
-
NegativeBinomial
public NegativeBinomial()
Default constructor. Number of successes is set to one and probability of success is set to 0.5.
-
NegativeBinomial
public NegativeBinomial(int r, double p)
Create a distribution with the given number of successes and probability of success.- Parameters:
r
- the number of successes.p
- the probability of success.
-
-
Method Detail
-
cumulativeProbability
public double cumulativeProbability(int x) throws NumericException
The CDF for this distribution. This method returns P(X ≤ x).- Specified by:
cumulativeProbability
in classDiscreteDistribution
- Parameters:
x
- the value at which the CDF is evaluated.- Returns:
- CDF for this distribution.
- Throws:
NumericException
- if the cumulative probability can not be computed.
-
getNumberOfSuccesses
public int getNumberOfSuccesses()
Access the number of successes.- Returns:
- the number of successes.
-
getProbabilityOfSuccess
public double getProbabilityOfSuccess()
Access probability of success.- Returns:
- the probability of success.
-
inverseCumulativeProbability
public int inverseCumulativeProbability(double p) throws NumericException
The inverse CDF for this distribution. This method returns the largest x such that, P(X ≤ x) ≤ p. The return value must also satisfy P(X ≥ x) &ge 1 - p.- Specified by:
inverseCumulativeProbability
in classDiscreteDistribution
- Parameters:
p
- the cumulative probability.- Returns:
- x
- Throws:
NumericException
- if the inverse cumulative probability can not be computed.
-
probability
public double probability(int x)
The PMF for this distribution. This method returns P(X = x).- Specified by:
probability
in classDiscreteDistribution
- Parameters:
x
- the value at which the probability is evaluated.- Returns:
- PMF for this distribution.
-
setNumberOfSuccesses
public void setNumberOfSuccesses(int r)
Modify the number of successes.- Parameters:
r
- the new number of successes value.
-
getMean
public double getMean()
Get mean value. Calculated as numberOfSuccesses * probabilityOfSuccess / (1-probabilityOfSuccess)- Parameters:
r
- the new number of successes value.
-
getVariance
public double getVariance()
Get mean value. Calculated as numberOfSuccesses * probabilityOfSuccess / (1-probabilityOfSuccess)**2- Parameters:
r
- the new number of successes value.
-
setProbabilityOfSuccess
public void setProbabilityOfSuccess(double p)
Modify probability of success.- Parameters:
p
- the new probability of success value.
-
-
DMelt 3.0 © DataMelt by jWork.ORG