Implementation of the Pascal distribution. The Pascal distribution is a special case of the Negative Binomial distribution where the number of successes parameter is an integer.
There are various ways to express the probability mass and distribution
functions for the Pascal distribution. The present implementation represents
the distribution of the number of failures before r successes occur.
This is the convention adopted in e.g.
MathWorld,
but not in
Wikipedia.
For a random variable X whose values are distributed according to this
distribution, the probability mass function is given by
P(X = k) = C(k + r - 1, r - 1) * p^r * (1 - p)^k,
where r is the number of successes, p is the probability of
success, and X is the total number of failures. C(n, k) is
the binomial coefficient (n choose k). The mean and variance
of X are
E(X) = (1 - p) * r / p, var(X) = (1 - p) * r / p^2.
Finally, the cumulative distribution function is given by
P(X <= k) = I(p, r, k + 1),
where I is the regularized incomplete Beta function.
| Modifier and Type | Field and Description |
|---|---|
| private final double | log1mProbabilityOfSuccess
The value of |
| private final double | logProbabilityOfSuccess
The value of |
| private final int | numberOfSuccesses
The number of successes. |
| private final double | probabilityOfSuccess
The probability of success. |
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| public | PascalDistribution(int
Number of successes. r, double Probability of success. p)Create a Pascal distribution with the given number of successes and probability of success. |
| public | PascalDistribution(RandomGenerator
Random number generator. rng, int Number of successes. r, double Probability of success. p)Create a Pascal distribution with the given number of successes and probability of success. |
| Modifier and Type | Method and Description |
|---|---|
| public double | cumulativeProbability(int
the point at which the CDF is evaluated x)Implements org. For a random variable |
| public int | Returns: the number of successes.Access the number of successes for this distribution. |
| public double | getNumericalMean()
Implements org. Use this method to get the numerical value of the mean of this distribution. |
| public double | getNumericalVariance()
Implements org. Use this method to get the numerical value of the variance of this distribution. |
| public double | Returns: the probability of success.Access the probability of success for this distribution. |
| public int | Returns: lower bound of the support (always 0)Implements org. Access the lower bound of the support. |
| public int | Returns: upper bound of the support (alwaysInteger.MAX_VALUE
for positive infinity)Implements org. Access the upper bound of the support. |
| public boolean | Returns: trueImplements org. Use this method to get information about whether the support is connected, i.e. whether all integers between the lower and upper bound of the support are included in the support. |
| public double | logProbability(int
the point at which the PMF is evaluated x)Overrides org. For a random variable |
| public double | probability(int
the point at which the PMF is evaluated x)Implements org. For a random variable |
| log1mProbabilityOfSuccess | back to summary |
|---|---|
| private final double log1mProbabilityOfSuccess The value of | |
| logProbabilityOfSuccess | back to summary |
|---|---|
| private final double logProbabilityOfSuccess The value of | |
| numberOfSuccesses | back to summary |
|---|---|
| private final int numberOfSuccesses The number of successes. | |
| probabilityOfSuccess | back to summary |
|---|---|
| private final double probabilityOfSuccess The probability of success. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serializable version identifier. | |
| PascalDistribution | back to summary |
|---|---|
| public PascalDistribution(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException Create a Pascal distribution with the given number of successes and probability of success. Note this constructor will implicitly create an instance of
| |
| PascalDistribution | back to summary |
|---|---|
| public PascalDistribution(RandomGenerator rng, int r, double p) throws NotStrictlyPositiveException, OutOfRangeException Create a Pascal distribution with the given number of successes and probability of success.
| |
| cumulativeProbability | back to summary |
|---|---|
| public double cumulativeProbability(int x) Implements org. Doc from org. For a random variable
| |
| getNumberOfSuccesses | back to summary |
|---|---|
| public int getNumberOfSuccesses() Access the number of successes for this distribution.
| |
| getNumericalMean | back to summary |
|---|---|
| public double getNumericalMean() Implements org. Doc from org. Use this method to get the numerical value of the mean of this
distribution.
For number of successes
| |
| getNumericalVariance | back to summary |
|---|---|
| public double getNumericalVariance() Implements org. Doc from org. Use this method to get the numerical value of the variance of this
distribution.
For number of successes
| |
| getProbabilityOfSuccess | back to summary |
|---|---|
| public double getProbabilityOfSuccess() Access the probability of success for this distribution.
| |
| getSupportLowerBound | back to summary |
|---|---|
| public int getSupportLowerBound() Implements org. Doc from org. Access the lower bound of the support. This method must return the same
value as
| |
| getSupportUpperBound | back to summary |
|---|---|
| public int getSupportUpperBound() Implements org. Doc from org. Access the upper bound of the support. This method must return the same
value as
Integer.MAX_VALUE.
| |
| isSupportConnected | back to summary |
|---|---|
| public boolean isSupportConnected() Implements org. Doc from org. Use this method to get information about whether the support is connected, i.e. whether all integers between the lower and upper bound of the support are included in the support. The support of this distribution is connected.
| |
| logProbability | back to summary |
|---|---|
| public double logProbability(int x) Overrides org. Doc from org. For a random variable
The default implementation simply computes the logarithm of
| |
| probability | back to summary |
|---|---|
| public double probability(int x) Implements org. Doc from org. For a random variable
| |