Class ZipfDistributionImpl
- java.lang.Object
 - 
- org.apache.commons.math.distribution.AbstractDistribution
 - 
- org.apache.commons.math.distribution.AbstractIntegerDistribution
 - 
- org.apache.commons.math.distribution.ZipfDistributionImpl
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,DiscreteDistribution,Distribution,IntegerDistribution,ZipfDistribution
public class ZipfDistributionImpl extends AbstractIntegerDistribution implements ZipfDistribution, java.io.Serializable
Implementation for theZipfDistribution.- See Also:
 - Serialized Form
 
 
- 
- 
Constructor Summary
Constructors Constructor Description ZipfDistributionImpl(int numberOfElements, double exponent)Create a new Zipf distribution with the given number of elements and exponent. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doublecumulativeProbability(int x)The probability distribution function P(X <= x) for a Zipf distribution.doublegetExponent()Get the exponent characterising the distribution.intgetNumberOfElements()Get the number of elements (e.g.intgetSupportLowerBound()Returns the lower bound of the support for the distribution.intgetSupportUpperBound()Returns the upper bound of the support for the distribution.doubleprobability(int x)The probability mass function P(X = x) for a Zipf distribution.voidsetExponent(double s)Deprecated.as of 2.1 (class will become immutable in 3.0)voidsetNumberOfElements(int n)Deprecated.as of 2.1 (class will become immutable in 3.0)- 
Methods inherited from class org.apache.commons.math.distribution.AbstractIntegerDistribution
cumulativeProbability, cumulativeProbability, cumulativeProbability, inverseCumulativeProbability, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive, probability, reseedRandomGenerator, sample, sample 
- 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.apache.commons.math.distribution.DiscreteDistribution
probability 
- 
Methods inherited from interface org.apache.commons.math.distribution.Distribution
cumulativeProbability, cumulativeProbability 
- 
Methods inherited from interface org.apache.commons.math.distribution.IntegerDistribution
cumulativeProbability, inverseCumulativeProbability 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
ZipfDistributionImpl
public ZipfDistributionImpl(int numberOfElements, double exponent) throws java.lang.IllegalArgumentExceptionCreate a new Zipf distribution with the given number of elements and exponent. Both values must be positive; otherwise anIllegalArgumentExceptionis thrown.- Parameters:
 numberOfElements- the number of elementsexponent- the exponent- Throws:
 java.lang.IllegalArgumentException- if n ≤ 0 or s ≤ 0.0
 
 - 
 
- 
Method Detail
- 
getNumberOfElements
public int getNumberOfElements()
Get the number of elements (e.g. corpus size) for the distribution.- Specified by:
 getNumberOfElementsin interfaceZipfDistribution- Returns:
 - the number of elements
 
 
- 
setNumberOfElements
@Deprecated public void setNumberOfElements(int n)
Deprecated.as of 2.1 (class will become immutable in 3.0)Set the number of elements (e.g. corpus size) for the distribution. The parameter value must be positive; otherwise anIllegalArgumentExceptionis thrown.- Specified by:
 setNumberOfElementsin interfaceZipfDistribution- Parameters:
 n- the number of elements- Throws:
 java.lang.IllegalArgumentException- if n ≤ 0
 
- 
getExponent
public double getExponent()
Get the exponent characterising the distribution.- Specified by:
 getExponentin interfaceZipfDistribution- Returns:
 - the exponent
 
 
- 
setExponent
@Deprecated public void setExponent(double s)
Deprecated.as of 2.1 (class will become immutable in 3.0)Set the exponent characterising the distribution. The parameter value must be positive; otherwise anIllegalArgumentExceptionis thrown.- Specified by:
 setExponentin interfaceZipfDistribution- Parameters:
 s- the exponent- Throws:
 java.lang.IllegalArgumentException- if s ≤ 0.0
 
- 
probability
public double probability(int x)
The probability mass function P(X = x) for a Zipf distribution.- Specified by:
 probabilityin interfaceIntegerDistribution- Parameters:
 x- the value at which the probability density function is evaluated.- Returns:
 - the value of the probability mass function at x
 
 
- 
cumulativeProbability
public double cumulativeProbability(int x)
The probability distribution function P(X <= x) for a Zipf distribution.- Specified by:
 cumulativeProbabilityin interfaceIntegerDistribution- Specified by:
 cumulativeProbabilityin classAbstractIntegerDistribution- Parameters:
 x- the value at which the PDF is evaluated.- Returns:
 - Zipf distribution function evaluated at x
 
 
- 
getSupportLowerBound
public int getSupportLowerBound()
Returns the lower bound of the support for the distribution. The lower bound of the support is always 1 no matter the parameters.- Returns:
 - lower bound of the support (always 1)
 - Since:
 - 2.2
 
 
- 
getSupportUpperBound
public int getSupportUpperBound()
Returns the upper bound of the support for the distribution. The upper bound of the support is the number of elements- Returns:
 - upper bound of the support
 - Since:
 - 2.2
 
 
 - 
 
 -