Learn R Programming

poweRlaw (version 0.20.2)

dpldis: Discrete powerlaw distribution.

Description

Density, distribution function and random number generation for the discrete power law distribution with parameters xmin and alpha.

Usage

dpldis(x, xmin, alpha, log = FALSE)

ppldis(q, xmin, alpha, lower.tail = TRUE)

rpldis(n, xmin, alpha, discrete_max = 1e+05)

Arguments

Value

dpldis returns the denisty, ppldis returns the distribution function and rpldis return random numbers.

Details

The Clausett, 2009 paper provides an algorithm for generating discrete random numbers. However, if this algorithm is implemented in R, it gives terrible performance. This is because the algorithm involves "growing vectors". Another problem is when alpha is close to 1, this can result in very large random number being generated (which means we need to calculate the discrete CDF).

The algorithm provided in this package generates true discrete random numbers up to 1e5 then switches to using continuous random numbers. This switching point can altered by changing the discrete_max argument.

In order to get a efficient power-law discrete random number generator, the algorithm needs to be implemented in C.

Examples

Run this code
xmin = 1; alpha = 1.5
x = xmin:100
plot(x, dpldis(x, xmin, alpha), type="l")
plot(x, ppldis(x, xmin, alpha), type="l", main="Distribution function")
rpldis(x, xmin, alpha)

Run the code above in your browser using DataLab