zipfman: Zipf-Mandelbrot Distributions

Description Usage Arguments Details Value Note References See Also Examples

Description

Density (mass), distribution function, quantile function, and random generation for the Zipf, Zipf-Mandelbrot, and zeta distributions.

Usage

1
2
3
4
5
6
dzipfman(x, s, b = NULL, N = NULL, log = FALSE)
pzipfman(q, s, b = NULL, N = NULL, lower.tail = TRUE, 
         log.p = FALSE)
qzipfman(p, s, b = NULL, N = NULL, lower.tail = TRUE, 
         log.p = FALSE)
rzipfman(n, s, b = NULL, N = NULL)

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. b must be specified for Zipf-Mandelbrot distributions.

N

The number of categories, which must be integer-valued for Zipf and Zipf-Mandelbrot distributions. For a zeta distribution, N = Inf must be used.

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≤ x], else P[X>x].

Details

The Zipf-Mandelbrot distribution has mass

p(x) = (x + b)^-s/∑_{i=1}^{N}(i + b)^(-s),

where x=1,…,N, s,b>0 are shape parameters, and N is the number of distinct categories. The Zipf distribution is just a special case of the Zipf-Mandelbrot distribution where the second shape parameter b=0. The zeta distribution has mass

p(x) = x^-λ/ζ(s),

where x=1,2,…, s>1 is the shape parameter, and ζ() is the Riemann zeta function given by:

ζ(t) = ∑_{i=1}^∞ 1/i^t<∞.

Note that the zeta distribution is just a special case of the Zipf distribution where s>1 and N goes to infinity.

Value

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

Note

These functions may be updated in a future version of the package so as to allow greater flexibility with the inputs.

References

Mandelbrot, B. B. (1965), Information Theory and Psycholinguistics. In B. B. Wolman and E. Nagel, editors. Scientific Psychology, Basic Books.

Young, D. S. (2013), Approximate Tolerance Limits for Zipf-Mandelbrot Distributions, Physica A: Statistical Mechanics and its Applications, 392, 1702–1711.

Zipf, G. K. (1949), Human Behavior and the Principle of Least Effort, Hafner.

Zornig, 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Randomly generated data from the Zipf distribution.

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

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

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

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

## Randomly generated data from the Zipf-Mandelbrot distribution.

set.seed(100)
x <- rzipfman(n = 150, 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)

## Randomly generated data from the zeta distribution.

set.seed(100)
x <- rzipfman(n = 100, s = 1.3, N = Inf)
hist(x, main = "Randomly Generated Data", prob = TRUE)

x.1 <- sort(x)
y <- dzipfman(x = x.1, s = 1.3, N = Inf)
lines(x.1, y, col = 2, lwd = 2)

plot(x.1, pzipfman(q = x.1, s = 1.3, N = Inf), type = "l", 
     xlab = "x", ylab = "Cumulative Probabilities")

qzipfman(p = 0.20, s = 1.3, lower.tail = FALSE, N = Inf)
qzipfman(p = 0.80, s = 1.3, N = Inf)

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
[1] 3
[1] 3
[1] 12
[1] 12
[1] 123
[1] 123

tolerance documentation built on Feb. 6, 2020, 5:08 p.m.

Related to zipfman in tolerance...