Learn R Programming

hyper2 (version 3.2)

zipf: Zipf's law

Description

A very short function that reproduces Zipf's law: a harmonic rank-probability distribution, formally

$$p(i)=\frac{i^{-1}}{\sum_{i=1}^{N} i^{-1}},\qquad i=1,\ldots,N$$

The volleyball dataset might reasonably be assumed to be zipf, but one can reject this hypothesis at \(5\%\), see the examples.

Usage

zipf(n)

Value

Returns a numeric vector summing to one

Arguments

n

Integer; if a hyper2 object is supplied this is interpreted as size(n)

Author

Robin K. S. Hankin

See Also

knownp.test

Examples

Run this code
zipf(icons)
knownp.test(volleyball,zipf(volleyball))

Run the code above in your browser using DataLab