Skip to contents

Create a ddf object for the Zipf distribution with the given parameters.

Usage

zipf(N, s = 1)

Arguments

N

A positive integer, the total number of elements.

s

A positive number, the exponent for the inverse power law. See ‘Details.’ (Default: 1)

Value

A ddf distribution as described above.

Details

Zipf's law is an empirical law stating that the relative frequency of the \(n\)-th entry in a list of measured values, ordered in decreasing order, is inversely proportional to \(n\).

This can be generalized and formalized by the following inverse power law with exponent \(s\):

The generalized Zipf distribution on \(N\) symbols has support \(\{1, \dots, N\}\) on which its probability mass function is given by $$p(k) = \frac{1}{H_{N, s}} \frac{1}{k^s},$$ where \(H_{N, s}\) is a generalized harmonic number: $$H_{N, s} = \sum_{k=1}^{N} \frac{1}{k^s}.$$

For some examples where Zipf's law occurs and further details, we recommend the below linked Wikipedia article.

See also

Examples

# The Zipf distribution on 5 elements
zipf(5)
#> Zipf distribution on N = 5 elements with parameter s = 1 
#> 
#> Support:
#> [1] 1 2 3 4 5
#> 
#> Probabilities:
#> [1] 0.43795620 0.21897810 0.14598540 0.10948905 0.08759124