public class ZipfDistributionImpl extends AbstractIntegerDistribution implements ZipfDistribution, Serializable
ZipfDistribution
.Modifier and Type | Field and Description |
---|---|
private double |
exponent
Exponent parameter of the distribution.
|
private int |
numberOfElements
Number of elements.
|
private static long |
serialVersionUID
Serializable version identifier.
|
randomData
Constructor and Description |
---|
ZipfDistributionImpl(int numberOfElements,
double exponent)
Create a new Zipf distribution with the given number of elements and
exponent.
|
Modifier and Type | Method and Description |
---|---|
double |
cumulativeProbability(int x)
The probability distribution function P(X <= x) for a Zipf distribution.
|
private double |
generalizedHarmonic(int n,
double m)
Calculates the Nth generalized harmonic number.
|
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. |
double |
getExponent()
Get the exponent characterising the distribution.
|
int |
getNumberOfElements()
Get the number of elements (e.g.
|
protected double |
getNumericalMean()
Returns the mean.
|
protected double |
getNumericalVariance()
Returns the variance.
|
int |
getSupportLowerBound()
Returns the lower bound of the support for the distribution.
|
int |
getSupportUpperBound()
Returns the upper bound of the support for the distribution.
|
double |
probability(int x)
The probability mass function P(X = x) for a Zipf distribution.
|
void |
setExponent(double s)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setExponentInternal(double s)
Set the exponent characterising the distribution.
|
void |
setNumberOfElements(int n)
Deprecated.
as of 2.1 (class will become immutable in 3.0)
|
private void |
setNumberOfElementsInternal(int n)
Set the number of elements (e.g.
|
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 numberOfElements
private double exponent
public ZipfDistributionImpl(int numberOfElements, double exponent) throws IllegalArgumentException
IllegalArgumentException
is thrown.numberOfElements
- the number of elementsexponent
- the exponentIllegalArgumentException
- if n ≤ 0 or s ≤ 0.0public int getNumberOfElements()
getNumberOfElements
in interface ZipfDistribution
@Deprecated public void setNumberOfElements(int n)
IllegalArgumentException
is thrown.setNumberOfElements
in interface ZipfDistribution
n
- the number of elementsIllegalArgumentException
- if n ≤ 0private void setNumberOfElementsInternal(int n) throws IllegalArgumentException
IllegalArgumentException
is thrown.n
- the number of elementsIllegalArgumentException
- if n ≤ 0public double getExponent()
getExponent
in interface ZipfDistribution
@Deprecated public void setExponent(double s)
IllegalArgumentException
is thrown.setExponent
in interface ZipfDistribution
s
- the exponentIllegalArgumentException
- if s ≤ 0.0private void setExponentInternal(double s) throws IllegalArgumentException
IllegalArgumentException
is thrown.s
- the exponentIllegalArgumentException
- if s ≤ 0.0public double probability(int x)
probability
in interface IntegerDistribution
x
- the value at which the probability density function is evaluated.public double cumulativeProbability(int x)
cumulativeProbability
in interface IntegerDistribution
cumulativeProbability
in class AbstractIntegerDistribution
x
- the value at which the PDF is evaluated.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 double generalizedHarmonic(int n, double m)
n
- the term in the series to calculate (must be ≥ 1)m
- the exponent; special case m == 1.0 is the harmonic seriespublic int getSupportLowerBound()
public int getSupportUpperBound()
protected double getNumericalMean()
Hs1 / Hs
where
Hs1 = generalizedHarmonic(N, s - 1)
Hs = generalizedHarmonic(N, s)
protected double getNumericalVariance()
(Hs2 / Hs) - (Hs1^2 / Hs^2)
where
Hs2 = generalizedHarmonic(N, s - 2)
Hs1 = generalizedHarmonic(N, s - 1)
Hs = generalizedHarmonic(N, s)
Copyright (c) 2003-2014 Apache Software Foundation