Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

tolerance (version 0.4.0)

ZipfMandelbrot: The Zipf-Mandelbrot Distribution

Description

Density (mass), distribution function, quantile function, and random generation for the Zipf-Mandelbrot distribution with N categories and shape parameters s and b.

Usage

dzipfman(x, s, b, N, log = FALSE)
pzipfman(q, s, b, N, lower.tail = TRUE, log.p = FALSE)
qzipfman(p, s, b, N, lower.tail = TRUE, log.p = FALSE)
rzipfman(n, s, b, N)

Arguments

x, q
Vector of quantiles.
p
Vector of probabilities.
n
The number of observations. If length>1, then the length is taken to be the number required.
s, b
The shape parameters, both of which must be greater than 0.
N
The number of categories, which must be integer-valued.
log, log.p
Logical vectors. If TRUE, then the probabilities are given as log(p).
lower.tail
Logical vector. If TRUE, then probabilities are $P[X\le x]$, else $P[X>x]$.

Value

  • dzipfman gives the density (mass), pzipfman gives the distribution function, qzipfman gives the quantile function, and rzipfman generates random deviates.

Details

The Zipf-Mandelbrot distribution has mass p(x)=(x+δ)λi=1N(i+δ)λ, where $x=1,\ldots,N$, $\lambda,\delta>0$ are shape parameters, and N is the number of distinct categories. Note that the Zipf-Mandelbrot distribution is just a generalization of the Zipf distribution where the second shape parameter b=0.

References

Mandelbrot, B. B. (1965), Information Theory and Psycholinguistics. In B. B. Wolman and E. Nagel, editors. Scientific Psychology, Basic Books.\ Zipf, G. K. (1949), Human Behavior and the Principle of Least Effort, Hafner.\ Z"{o}rnig, P. and Altmann, G. (1995), Unified Representation of Zipf Distributions, Computational Statistics and Data Analysis, 19, 461--473.

See Also

runif and .Random.seed about random number generation.

Examples

Run this code
## Randomly generated data from the Zipf-Mandelbrot distribution.

set.seed(100)
x <- rzipfman(n = 500, s = 2, b = 3, N = 100)
hist(x, main = "Randomly Generated Data", prob = TRUE)

x.1 <- sort(x)
y <- dzipfman(x = x.1, s = 2, b = 3, N = 100)
lines(x.1, y, col = 2, lwd = 2)

plot(x.1, pzipfman(q = x.1, s = 2, b = 3, N = 100), type = "l", 
     xlab = "x", ylab = "Cumulative Probabilities")

qzipfman(p = 0.20, s = 2, b = 3, N = 100, lower.tail = FALSE)
qzipfman(p = 0.80, s = 2, b = 3, N = 100)

Run the code above in your browser using DataLab