The Zipf-Mandelbrot Distribution
zipfmbUC.RdDensity, distribution function, quantile function and random generation for the Mandelbrot distribution.
Usage
dzipfmb(x, shape, start = 1, log = FALSE)
pzipfmb(q, shape, start = 1, lower.tail = TRUE, log.p = FALSE)
qzipfmb(p, shape, start = 1)
rzipfmb(n, shape, start = 1)Arguments
- x
vector of (non-negative integer) quantiles.
- q
vector of quantiles.
- p
vector of probabilities.
- n
number of random values to return.
- shape
vector of positive shape parameter.
- start
integer, the minimum value of the support of the distribution.
- 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 probability mass function of the Zipf-Mandelbrot distribution is given by $$\Pr(Y=y;s) = \frac{s \; \Gamma(y_{min})}{\Gamma(y_{min}-s)} \cdot \frac{\Gamma(y-s)}{\Gamma(y+1)}$$ where \(0 \leq b < 1\) and the starting value start being by default 1.
Value
dzipfmb gives the density,
pzipfmb gives the distribution function,
qzipfmb gives the quantile function, and
rzipfmb generates random deviates.
References
Mandelbrot, B. (1961). On the theory of word frequencies and on related Markovian models of discourse. In R. Jakobson, Structure of Language and its Mathematical Aspects, pp. 190–219, Providence, RI, USA. American Mathematical Society.
Moreno-Sanchez, I. and Font-Clos, F. and Corral, A. (2016). Large-Scale Analysis of Zipf's Law in English Texts. PLos ONE, 11(1), 1–19.
See also
Zipf.
Examples
aa <- 1:10
(pp <- pzipfmb(aa, shape = 0.5, start = 1))
#> [1] 0.5000000 0.6250000 0.6875000 0.7265625 0.7539062 0.7744141 0.7905273
#> [8] 0.8036194 0.8145294 0.8238029
cumsum(dzipfmb(aa, shape = 0.5, start = 1)) # Should be same
#> [1] 0.5000000 0.6250000 0.6875000 0.7265625 0.7539062 0.7744141 0.7905273
#> [8] 0.8036194 0.8145294 0.8238029
qzipfmb(pp, shape = 0.5, start = 1) - aa # Should be all 0s
#> [1] 0 0 0 0 0 0 0 0 0 0
rdiffzeta(30, 0.5)
#> [1] 357 1 4 1 1 8 1 2353761 9
#> [10] 2 1 469 20 33 1 52 207 1
#> [19] 5589 1 6 3 53 3 87 1 1
#> [28] 12 1 1
if (FALSE) x <- 1:10
plot(x, dzipfmb(x, shape = 0.5), type = "h", ylim = 0:1,
sub = "shape=0.5", las = 1, col = "blue", ylab = "Probability",
main = "Zipf-Mandelbrot distribution: blue=PMF; orange=CDF")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
lines(x+0.1, pzipfmb(x, shape = 0.5), col = "red", lty = 3, type = "h")
#> Error: object 'x' not found
# \dontrun{}