ZipfDistribution Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.1.2
public class ZipfDistribution : DiscreteDistribution
- Inheritance
- Object → Distribution → DiscreteDistribution → ZipfDistribution
Remarks
The Zipf distribution is a discrete probability distribution commonly used to model the frequency of occurrence of distinct objects in a collection, where items are ordered from most to least frequent. It is characterized by its shape parameter a > 1, which controls how quickly the probabilities decay.
The probability mass function of the Zipf distribution is:
The Zipf distribution is sometimes called the zeta distribution.
The Zipf distribution is the limit distribution of the ZipfianDistribution where the second (integer) parameter approaches infinity. For the distribution to exist, the shape parameter of the distribution must be greater than one.
This distribution is often used to model:
- Word frequency in natural languages
- City population sizes
- Website traffic patterns
- Income distribution rankings
- Scientific citation counts
When the parameter a approaches 1 from above, the distribution becomes increasingly heavy-tailed. For values of a ≤ 1, the distribution is not properly normalized (the sum of probabilities would diverge).
Example
The following example demonstrates creating a Zipf distribution with a non-standard parameter and using its properties and methods:
// Create a Zipf distribution with shape parameter 2.5
var zipf = new ZipfDistribution(2.5);
// Distribution parameters
Console.WriteLine($"Distribution: Zipf(a = 2.5)");
// Distribution functions
Console.WriteLine("\nDistribution functions:");
Console.WriteLine($"P(X = 1) = {zipf.Probability(1)}");
Console.WriteLine($"P(X = 2) = {zipf.Probability(2)}");
Console.WriteLine($"P(X = 5) = {zipf.Probability(5)}");
Console.WriteLine($"Log P(X = 10) = {zipf.LogProbability(10)}");
Console.WriteLine($"CDF(5) = {zipf.DistributionFunction(5)}");
// Moments
Console.WriteLine("\nMoments:");
Console.WriteLine($"Mean = {zipf.Mean}");
Console.WriteLine($"Variance = {zipf.Variance}");
Constructors
Zipf | Constructs a new Zipf distribution with the specified shape parameter. |
Properties
Capabilities |
Gets a value that indicates the capabilities of the distribution class.
(Inherited from Distribution) |
Entropy |
Gets the entropy of the distribution.
(Inherited from Distribution) |
Exponent | Gets the value of the exponent. |
IsUnimodal |
Gets whether the distribution has one or more modes.
(Inherited from DiscreteDistribution) |
Kurtosis |
Gets the kurtosis of the distribution.
(Overrides Distribution.Kurtosis) |
Mean |
Gets the mean or expectation value of the distribution.
(Overrides Distribution.Mean) |
Mode |
Gets the mode of the distribution.
(Inherited from DiscreteDistribution) |
Number |
Gets the number of modes of the distribution.
(Inherited from DiscreteDistribution) |
Skewness |
Gets the skewness of the distribution.
(Overrides Distribution.Skewness) |
Standard |
Gets the standard deviation of the distribution.
(Inherited from Distribution) |
Statistic |
Gets the common symbol to describe a statistic
from the distribution.
(Inherited from Distribution) |
Variance |
Gets the variance of the distribution.
(Overrides Distribution.Variance) |
Methods
Distribution |
Gets the probability of obtaining an outcome less than
or equal to a specified value.
(Overrides DiscreteDistribution.DistributionFunction(Int32)) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
Get |
Returns an array that contains all the modes of the distribution.
(Inherited from DiscreteDistribution) |
Get |
Returns a histogram whose bins contain the expected number of samples
from the distribution for a given total number of samples.
(Inherited from DiscreteDistribution) |
Get |
Returns a histogram whose bins contain the expected number of samples
from the distribution for a given total number of samples.
(Inherited from DiscreteDistribution) |
Get |
Returns a histogram whose bins contain the expected number of samples
from the distribution for a given total number of samples.
(Inherited from DiscreteDistribution) |
Get | Serves as the default hash function. (Inherited from Object) |
Get |
Returns a sequence of random samples from the distribution.
(Inherited from DiscreteDistribution) |
Get |
Returns a sequence of random samples from the distribution.
(Inherited from DiscreteDistribution) |
Get |
Returns a sequence of random samples of the specified length from the distribution.
(Inherited from DiscreteDistribution) |
Get | Gets the Type of the current instance. (Inherited from Object) |
Inverse |
Returns the inverse of the distribution function.
(Inherited from DiscreteDistribution) |
Left |
Gets the probability of obtaining a sample that is less than or less than or equal to the specified upper bound.
(Inherited from DiscreteDistribution) |
Log |
Returns the logarithm of the probability of obtaining
a specific integer value in the distribution.
(Overrides DiscreteDistribution.LogProbability(Int32)) |
Memberwise | Creates a shallow copy of the current Object. (Inherited from Object) |
Probability( |
Returns the probability of obtaining a specific integer
value in the distribution.
(Overrides DiscreteDistribution.Probability(Int32)) |
Probability( |
Gets the probability of obtaining a sample that falls
within the specified interval from the distribution.
(Inherited from DiscreteDistribution) |
Right |
Gets the probability of obtaining a sample that is less than or less than or equal to the specified upper bound.
(Inherited from DiscreteDistribution) |
Sample() |
Returns a random sample from the distribution.
(Inherited from DiscreteDistribution) |
Sample( |
Returns a vector of random samples from the distribution.
(Inherited from DiscreteDistribution) |
Sample( |
Returns a random sample from the distribution.
(Overrides DiscreteDistribution.Sample(Random)) |
Sample( |
Returns a vector of random samples from the distribution.
(Inherited from DiscreteDistribution) |
Sample( |
Fills an Int32 array with random numbers.
(Inherited from DiscreteDistribution) |
Sample( |
Fills an Int32 array with random numbers from this DiscreteDistribution.
(Inherited from DiscreteDistribution) |
ToString | Returns a string that represents the current object. (Inherited from Object) |
Two |
Gets the probability of obtaining a sample that is less than or less than or equal to the specified upper bound.
(Inherited from DiscreteDistribution) |