dzipf {sads}R Documentation

Zipf distribution

Description

Density, distribution function, quantile function and random generation for Zipf distribution with parameters N and s.

Usage

dzipf( x, N, s, log=FALSE)
pzipf( q, N, s, lower.tail=TRUE, log.p=FALSE)
qzipf( p, N, s, lower.tail = TRUE, log.p = FALSE)
rzipf( n, N, s)

Arguments

x

vector of (non-negative integer) quantiles. In the context of species abundance distributions, this is a vector of abundance ranks of species in a sample.

q

vector of (non-negative integer) quantiles. In the context of species abundance distributions, a vector of abundance ranks of species in a sample.

n

number of random values to return.

p

vector of probabilities.

N

positive integer 0 < N < Inf, total number of elements of a collection. In the context of species abundance distributions, usually the number of species in a sample.

s

positive real s > 0; Zipf's exponent

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].

Details

The Zipf distribution describes the probability or frequency of occurrence of a given element from a set of N elements. According to Zipf's law, this probability is inversely proportional to a power s of the frequency rank of the element in the set. The density function is

p(x) = ((x+v)^(-s)) / sum(((1:N)+v)^(-s))

Since p(x) is proportional to a power of x, the Zipf distribution is a power distribution. The Zeta distribution is a special case at the limit N -> Inf.

The Zipf distribution has a wide range of applications (Li 2011). One of its best known applications is describing the probability of occurrence of a given word that has a ranking x in a corpus with a total of N words. It can also be used to describe the probability of the abundance rank of a given species in a sample or assemblage of N species.

Value

dzipf gives the (log) density, pzipf gives the (log) distribution function, qzipf gives the quantile function.

Author(s)

Paulo I Prado prado@ib.usp.br and Murilo Dantas Miranda.

References

Johnson N. L., Kemp, A. W. and Kotz S. (2005) Univariate Discrete Distributions, 3rd edition, Hoboken, New Jersey: Wiley. Section 11.2.20.

Li, W. (2002) Zipf's Law everywhere. Glottometrics 5:14-21

Zipf's Law. http://en.wikipedia.org/wiki/Zipf's_law.

See Also

dzipf and rzipf and related functions in zipfR package; Zeta for zeta distribution in VGAM package. fitzipf to fit Zipf distribution as a rank-abundance model.

Examples

x <- 1:20
PDF <- dzipf(x=x, N=100, s=2)
CDF <- pzipf(q=x, N=100, s=2)
par(mfrow=c(1,2))
plot(x,CDF, ylab="Cumulative Probability", type="b",
     main="Zipf distribution, CDF")
plot(x,PDF, ylab="Probability", type="h",
     main="Zipf distribution, PDF")
par(mfrow=c(1,1))

## quantile is the inverse of CDF
all.equal( qzipf(CDF, N=100, s=2), x) # should be TRUE

## Zipf distribution is discrete hence
all.equal( sum(dzipf(1:10, N=10, s=2)), pzipf(10, N=10, s=2)) # should be TRUE

[Package sads version 0.4.2 Index]