Zipf | R Documentation |
Density, distribution function, quantile function and random generation for the Zipf distribution.
dzipf(x, N, shape, log = FALSE)
pzipf(q, N, shape, log.p = FALSE)
qzipf(p, N, shape)
rzipf(n, N, shape)
x , q , p , n |
Same as |
N , shape |
the number of elements, and the exponent characterizing the
distribution.
See |
log , log.p |
Same meaning as in |
This is a finite version of the zeta distribution.
See zetaff
for more details.
In general, these functions runs slower and slower as N
increases.
dzipf
gives the density,
pzipf
gives the cumulative distribution function,
qzipf
gives the quantile function, and
rzipf
generates random deviates.
T. W. Yee
zipf
,
Zipfmb
.
N <- 10; shape <- 0.5; y <- 1:N
proby <- dzipf(y, N = N, shape = shape)
## Not run: plot(proby ~ y, type = "h", col = "blue",
ylim = c(0, 0.2), ylab = "Probability", lwd = 2, las = 1,
main = paste0("Zipf(N = ", N, ", shape = ", shape, ")"))
## End(Not run)
sum(proby) # Should be 1
max(abs(cumsum(proby) - pzipf(y, N = N, shape = shape))) # 0?
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.