public class HypergeometricDistributionImpl extends AbstractIntegerDistribution implements HypergeometricDistribution, java.io.Serializable
HypergeometricDistribution
.Modifier and Type | Field and Description |
---|---|
private int |
numberOfSuccesses
The number of successes in the population.
|
private int |
populationSize
The population size.
|
private int |
sampleSize
The sample size.
|
private static long |
serialVersionUID
Serializable version identifier
|
randomData
Constructor and Description |
---|
HypergeometricDistributionImpl(int populationSize,
int numberOfSuccesses,
int sampleSize)
Construct a new hypergeometric distribution with the given the population
size, the number of successes in the population, and the sample size.
|
Modifier and Type | Method and Description |
---|---|
double |
cumulativeProbability(int x)
For this distribution, X, this method returns P(X ≤ x).
|
private int[] |
getDomain(int n,
int m,
int k)
Return the domain for the given hypergeometric distribution parameters.
|
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. |
private int |
getLowerDomain(int n,
int m,
int k)
Return the lowest domain value for the given hypergeometric distribution
parameters.
|
int |
getNumberOfSuccesses()
Access the number of successes.
|
protected double |
getNumericalMean()
Returns the mean.
|
double |
getNumericalVariance()
Returns the variance.
|
int |
getPopulationSize()
Access the population size.
|
int |
getSampleSize()
Access the sample size.
|
int |
getSupportLowerBound()
Returns the lower bound for the support for the distribution.
|
int |
getSupportUpperBound()
Returns the upper bound for the support of the distribution.
|
private int |
getUpperDomain(int m,
int k)
Return the highest domain value for the given hypergeometric distribution
parameters.
|
private double |
innerCumulativeProbability(int x0,
int x1,
int dx,
int n,
int m,
int k)
For this distribution, X, this method returns P(x0 ≤ X ≤ x1).
|
double |
probability(int x)
For this distribution, X, this method returns P(X = x).
|
private double |
probability(int n,
int m,
int k,
int x)
For the distribution, X, defined by the given hypergeometric distribution
parameters, this method returns P(X = x).
|
void |
setNumberOfSuccesses(int num)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setNumberOfSuccessesInternal(int num)
Modify the number of successes.
|
void |
setPopulationSize(int size)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setPopulationSizeInternal(int size)
Modify the population size.
|
void |
setSampleSize(int size)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setSampleSizeInternal(int size)
Modify the sample size.
|
double |
upperCumulativeProbability(int x)
For this distribution, X, this method returns P(X ≥ x).
|
cumulativeProbability, cumulativeProbability, cumulativeProbability, inverseCumulativeProbability, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive, probability, reseedRandomGenerator, sample, sample
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cumulativeProbability, inverseCumulativeProbability
probability
cumulativeProbability, cumulativeProbability
private static final long serialVersionUID
private int numberOfSuccesses
private int populationSize
private int sampleSize
public HypergeometricDistributionImpl(int populationSize, int numberOfSuccesses, int sampleSize)
populationSize
- the population size.numberOfSuccesses
- number of successes in the population.sampleSize
- the sample size.public double cumulativeProbability(int x)
cumulativeProbability
in interface IntegerDistribution
cumulativeProbability
in class AbstractIntegerDistribution
x
- the value at which the PDF is evaluated.private int[] getDomain(int n, int m, int k)
n
- the population size.m
- number of successes in the population.k
- the sample size.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
private int getLowerDomain(int n, int m, int k)
n
- the population size.m
- number of successes in the population.k
- the sample size.public int getNumberOfSuccesses()
getNumberOfSuccesses
in interface HypergeometricDistribution
public int getPopulationSize()
getPopulationSize
in interface HypergeometricDistribution
public int getSampleSize()
getSampleSize
in interface HypergeometricDistribution
private int getUpperDomain(int m, int k)
m
- number of successes in the population.k
- the sample size.public double probability(int x)
probability
in interface IntegerDistribution
x
- the value at which the PMF is evaluated.private double probability(int n, int m, int k, int x)
n
- the population size.m
- number of successes in the population.k
- the sample size.x
- the value at which the PMF is evaluated.@Deprecated public void setNumberOfSuccesses(int num)
setNumberOfSuccesses
in interface HypergeometricDistribution
num
- the new number of successes.java.lang.IllegalArgumentException
- if num
is negative.private void setNumberOfSuccessesInternal(int num)
num
- the new number of successes.java.lang.IllegalArgumentException
- if num
is negative.@Deprecated public void setPopulationSize(int size)
setPopulationSize
in interface HypergeometricDistribution
size
- the new population size.java.lang.IllegalArgumentException
- if size
is not positive.private void setPopulationSizeInternal(int size)
size
- the new population size.java.lang.IllegalArgumentException
- if size
is not positive.@Deprecated public void setSampleSize(int size)
setSampleSize
in interface HypergeometricDistribution
size
- the new sample size.java.lang.IllegalArgumentException
- if size
is negative.private void setSampleSizeInternal(int size)
size
- the new sample size.java.lang.IllegalArgumentException
- if size
is negative.public double upperCumulativeProbability(int x)
x
- the value at which the CDF is evaluated.private double innerCumulativeProbability(int x0, int x1, int dx, int n, int m, int k)
x0
- the inclusive, lower boundx1
- the inclusive, upper bounddx
- the direction of summation. 1 indicates summing from x0 to x1.
0 indicates summing from x1 to x0.n
- the population size.m
- number of successes in the population.k
- the sample size.public int getSupportLowerBound()
N
,
number of successes m
, and
sample size n
,
the lower bound of the support is
max(0, n + m - N)
public int getSupportUpperBound()
m
and
sample size n
,
the upper bound of the support is
min(m, n)
protected double getNumericalMean()
N
,
number of successes m
, and
sample size n
, the mean is
n * m / N
public double getNumericalVariance()
N
,
number of successes m
, and
sample size n
, the variance is
[ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]
Copyright (c) 2003-2013 Apache Software Foundation