public class ZipfDistribution extends AbstractDiscreteDistribution
ZipfDistributionclass provides a finite distribution parameterized by a positive integer number of outcomes with outcome probability inversely proportional to the rank of the outcome (ordered by probablity). Many natural language phenomena such as unigram word probabilities and named-entity probabilities follow roughly a Zipf distribution.
The Zipf probability distribution
outcomes is defined by assigning a probability to the
r outcome, for
Zipfn(r) = (1/r)/Zn
Znis the normalizing factor for a Zipf distribution with
Zn = Σ1<=j<=n 1/j
The Zipf distribution class provides a method for returning the entropy of the Zipf distribution. It also provides a static method for returning a Zipf distribution's probabilities in rank order. This latter method is useful for comparing observed distributions to that expected from a Zipf distribution.
For more information, see:
|Constructor and Description|
Construct a Constant Zipf distribution with the specified number of outcomes.
|Modifier and Type||Method and Description|
Returns the maximum outcome, which is just the number of outcomes.
Returns one, the minimum outcome in a Zipf distribution.
Returns the number of non-zero outcomes for this Zipf distribution.
Returns the probability of the outcome at the specified rank.
Returns the array of probabilities indexed by rank for the Zipf distribution with the specified number of outcomes.
cumulativeProbability, cumulativeProbabilityGreater, cumulativeProbabilityLess, entropy, log2Probability, mean, variance
public ZipfDistribution(int numOutcomes)
numOutcomes- Number of outcomes for the distribution.
IllegalArgumentException- If the number of outcomes specified is not positive.
public long minOutcome()
public long maxOutcome()
public int numOutcomes()
public double probability(long rank)
0.0for non-positive ranks or ranks greater than the number of ranks in this distribution.
public static double zipfDistribution(int numOutcomes)
numOutcomes- Number of outcomes.