org.apache.commons.math.distribution
public class PascalDistributionImpl extends AbstractIntegerDistribution implements PascalDistribution, java.io.Serializable
PascalDistribution
.Modifier and Type | Field and Description |
---|---|
private int |
numberOfSuccesses
The number of successes
|
private double |
probabilityOfSuccess
The probability of success
|
private static long |
serialVersionUID
Serializable version identifier
|
randomData
Constructor and Description |
---|
PascalDistributionImpl(int r,
double p)
Create a Pascal distribution with the given number of trials and
probability of success.
|
Modifier and Type | Method and Description |
---|---|
double |
cumulativeProbability(int x)
For this distribution, X, this method returns P(X ≤ x).
|
protected int |
getDomainLowerBound(double p)
Access the domain value lower bound, based on
p , used to
bracket a PDF root. |
protected int |
getDomainUpperBound(double p)
Access the domain value upper bound, based on
p , used to
bracket a PDF root. |
int |
getNumberOfSuccesses()
Access the number of successes for this distribution.
|
double |
getNumericalMean()
Returns the mean.
|
double |
getNumericalVariance()
Returns the variance.
|
double |
getProbabilityOfSuccess()
Access the probability of success for this distribution.
|
int |
getSupportLowerBound()
Returns the lower bound of the support for the distribution.
|
int |
getSupportUpperBound()
Returns the upper bound of the support for the distribution.
|
int |
inverseCumulativeProbability(double p)
For this distribution, X, this method returns the largest x, such that
P(X ≤ x) ≤
p . |
double |
probability(int x)
For this distribution, X, this method returns P(X = x).
|
void |
setNumberOfSuccesses(int successes)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setNumberOfSuccessesInternal(int successes)
Change the number of successes for this distribution.
|
void |
setProbabilityOfSuccess(double p)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setProbabilityOfSuccessInternal(double p)
Change the probability of success for this distribution.
|
cumulativeProbability, cumulativeProbability, cumulativeProbability, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive, probability, reseedRandomGenerator, sample, sample
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cumulativeProbability
probability
cumulativeProbability, cumulativeProbability
private static final long serialVersionUID
private int numberOfSuccesses
private double probabilityOfSuccess
public PascalDistributionImpl(int r, double p)
r
- the number of successesp
- the probability of successpublic int getNumberOfSuccesses()
getNumberOfSuccesses
in interface PascalDistribution
public double getProbabilityOfSuccess()
getProbabilityOfSuccess
in interface PascalDistribution
@Deprecated public void setNumberOfSuccesses(int successes)
setNumberOfSuccesses
in interface PascalDistribution
successes
- the new number of successesjava.lang.IllegalArgumentException
- if successes
is not
positive.private void setNumberOfSuccessesInternal(int successes)
successes
- the new number of successesjava.lang.IllegalArgumentException
- if successes
is not
positive.@Deprecated public void setProbabilityOfSuccess(double p)
setProbabilityOfSuccess
in interface PascalDistribution
p
- the new probability of successjava.lang.IllegalArgumentException
- if p
is not a valid
probability.private void setProbabilityOfSuccessInternal(double p)
p
- the new probability of successjava.lang.IllegalArgumentException
- if p
is not a valid
probability.protected int getDomainLowerBound(double p)
p
, used to
bracket a PDF root.getDomainLowerBound
in class AbstractIntegerDistribution
p
- the desired probability for the critical valuep
protected int getDomainUpperBound(double p)
p
, used to
bracket a PDF root.getDomainUpperBound
in class AbstractIntegerDistribution
p
- the desired probability for the critical valuep
public double cumulativeProbability(int x) throws MathException
cumulativeProbability
in interface IntegerDistribution
cumulativeProbability
in class AbstractIntegerDistribution
x
- the value at which the PDF is evaluatedMathException
- if the cumulative probability can not be computed
due to convergence or other numerical errorspublic double probability(int x)
probability
in interface IntegerDistribution
x
- the value at which the PMF is evaluatedpublic int inverseCumulativeProbability(double p) throws MathException
p
.
Returns -1
for p=0 and Integer.MAX_VALUE
for p=1.
inverseCumulativeProbability
in interface IntegerDistribution
inverseCumulativeProbability
in class AbstractIntegerDistribution
p
- the desired probabilityMathException
- if the inverse cumulative probability can not be
computed due to convergence or other numerical errors.java.lang.IllegalArgumentException
- if p < 0 or p > 1public int getSupportLowerBound()
public int getSupportUpperBound()
Integer.MAX_VALUE
together with
AbstractIntegerDistribution.isSupportUpperBoundInclusive()
being false
Integer.MAX_VALUE
for positive infinity)public double getNumericalMean()
r
and
probability of success p
, the mean is
( r * p ) / ( 1 - p )
public double getNumericalVariance()
r
and
probability of success p
, the mean is
( r * p ) / ( 1 - p )^2
Copyright (c) 2003-2016 Apache Software Foundation