public class GeometricDistribution extends Object
DiscreteDistribution.Sampler
Constructor and Description 

GeometricDistribution(double p)
Creates a geometric distribution.

Modifier and Type  Method and Description 

DiscreteDistribution.Sampler 
createSampler(org.apache.commons.rng.UniformRandomProvider rng)
Creates a sampler.

double 
cumulativeProbability(int x)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(X <= x) . 
double 
getMean()
Gets the mean of this distribution.

double 
getProbabilityOfSuccess()
Access the probability of success for this distribution.

int 
getSupportLowerBound()
Gets the lower bound of the support.

int 
getSupportUpperBound()
Gets the upper bound of the support.

double 
getVariance()
Gets the variance of this distribution.

int 
inverseCumulativeProbability(double p)
Computes the quantile function of this distribution.

boolean 
isSupportConnected()
Indicates whether the support is connected, i.e.

double 
logProbability(int x)
For a random variable
X whose values are distributed according
to this distribution, this method returns log(P(X = x)) , where
log is the natural logarithm. 
double 
probability(int x)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(X = x) . 
double 
probability(int x0,
int x1)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1) . 
static int[] 
sample(int n,
DiscreteDistribution.Sampler sampler)
Utility function for allocating an array and filling it with
n
samples generated by the given sampler . 
public GeometricDistribution(double p)
p
 Probability of success.IllegalArgumentException
 if p <= 0
or p > 1
.public double getProbabilityOfSuccess()
public double probability(int x)
X
whose values are distributed according
to this distribution, this method returns P(X = x)
.
In other words, this method represents the probability mass function (PMF)
for the distribution.x
 Point at which the PMF is evaluated.x
.public double logProbability(int x)
X
whose values are distributed according
to this distribution, this method returns log(P(X = x))
, where
log
is the natural logarithm.x
 Point at which the PMF is evaluated.x
.public double cumulativeProbability(int x)
X
whose values are distributed according
to this distribution, this method returns P(X <= x)
.
In other, words, this method represents the (cumulative) distribution
function (CDF) for this distribution.x
 Point at which the CDF is evaluated.x
.public double getMean()
p
, the mean is (1  p) / p
.Double.NaN
if it is not defined.public double getVariance()
p
, the variance is
(1  p) / (p * p)
.Double.NaN
if it is not defined.public int getSupportLowerBound()
inverseCumulativeProbability(0)
, i.e.
inf {x in Z  P(X <= x) > 0}
.
By convention, Integer.MIN_VALUE
should be substituted
for negative infinity.
The lower bound of the support is always 0.public int getSupportUpperBound()
inverseCumulativeProbability(1)
, i.e.
inf {x in R  P(X <= x) = 1}
.
By convention, Integer.MAX_VALUE
should be substituted
for positive infinity.
The upper bound of the support is infinite (which we approximate as
Integer.MAX_VALUE
).public boolean isSupportConnected()
true
public int inverseCumulativeProbability(double p)
X
distributed according to this distribution,
the returned value is
inf{x in Z  P(X<=x) >= p}
for 0 < p <= 1
,inf{x in Z  P(X<=x) > 0}
for p = 0
.int
,
then Integer.MIN_VALUE
or Integer.MAX_VALUE
is returned.
The default implementation returns
DiscreteDistribution.getSupportLowerBound()
for p = 0
,DiscreteDistribution.getSupportUpperBound()
for p = 1
, andsolveInverseCumulativeProbability(double, int, int)
for
0 < p < 1
.inverseCumulativeProbability
in interface DiscreteDistribution
p
 Cumulative probability.p
quantile of this distribution
(largest 0quantile for p = 0
).public double probability(int x0, int x1)
X
whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1)
.
The default implementation uses the identity
P(x0 < X <= x1) = P(X <= x1)  P(X <= x0)
probability
in interface DiscreteDistribution
x0
 Lower bound (exclusive).x1
 Upper bound (inclusive).x0
and x1
, excluding the lower
and including the upper endpoint.public static int[] sample(int n, DiscreteDistribution.Sampler sampler)
n
samples generated by the given sampler
.n
 Number of samples.sampler
 Sampler.n
.public DiscreteDistribution.Sampler createSampler(org.apache.commons.rng.UniformRandomProvider rng)
createSampler
in interface DiscreteDistribution
rng
 Generator of uniformly distributed numbers.Copyright © 2018 The Apache Software Foundation. All rights reserved.