Random generation for the log-series distribution.

rlseries(n, size, alpha, show_progress = TRUE, check_arguments = TRUE)

Arguments

n

Number of observations.

size

The size of the distribution.

alpha

Fisher's \(\alpha\).

show_progress

If TRUE, a progress bar is shown during long computations.

check_arguments

If TRUE, the function arguments are verified. Should be set to FALSE to save time when the arguments have been checked elsewhere.

Value

A numeric vector with the random values drawn from the log-series distribution.

Details

Fast implementation of the random generation of a log-series distribution Fisher1943divent.

The complete set of functions (including density, distribution function and quantiles) can be found in package sads but this implementation of the random generation is much faster.

If size is too large, i.e. size + 1 can't be distinguished from size due to rounding, then an error is raised.

References

Examples

# Generate a community made of 10000 individuals with alpha=40
size <- 1E4
alpha <- 40
species_number <- -alpha * log(alpha / (size + alpha))
abundances <- rlseries(species_number, size = 1E5, alpha = 40)
# rCommunity() may be a better choice
autoplot(rcommunity(n = 1, size = 1E4, alpha = 40, distribution = "lseries"))