sdsu.algorithms.data
Class Zipf
java.lang.Object
|
+--sdsu.algorithms.data.ProbabilityDistribution
|
+--sdsu.algorithms.data.DiscreteProbability
|
+--sdsu.algorithms.data.NoInverseDistribution
|
+--sdsu.algorithms.data.Zipf
- public class Zipf
- extends NoInverseDistribution
The Zipfian distribution models the frequency of the word usage in written
English and the population of U.S. cities (amoung other things). When ranked
by frequency, the frequency
of the i'th is proportional to the frquency of the first item divided by i.
Reference: Handbook of Algorithms and Data Structures, G. H. Gonnet,
Addison-Wesley, 1984, pp 203.
- Version:
- 1.0 11 June 1997
- Author:
- Roger Whitney (whitney@cs.sdsu.edu)
Constructor Summary |
Zipf(int populationSize)
Returns a Zipf distribution. |
Method Summary |
double |
density(double sampleSpaceItem)
Returns the probability of an item in the sample
space will occur. |
double |
mean()
Returns the mean of the Bernoulli distribution |
double |
variance()
Returns the variance of the probability distribution |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Zipf
public Zipf(int populationSize)
- Returns a Zipf distribution.
- Parameters:
populationSize
- number of elements in the sample space.- Throws:
- OutOfBoundsException - thrown if populationSize is
not greater than zero.
density
public double density(double sampleSpaceItem)
throws OutOfBoundsException
- Returns the probability of an item in the sample
space will occur. sampleSpaceItem must be either
0 or 1.
- Parameters:
sampleSpaceItem
- an integer value in the interval
[1, populationSize]. Is cast to int in density.- Throws:
- OutOfBoundsException - thrown if sampleSpaceItem is not
either 0 or 1.
- Overrides:
- density in class ProbabilityDistribution
mean
public double mean()
- Returns the mean of the Bernoulli distribution
- Overrides:
- mean in class ProbabilityDistribution
variance
public double variance()
- Returns the variance of the probability distribution
- Overrides:
- variance in class ProbabilityDistribution