Skip to contents

The srpareto_custom() function generates random samples from a Pareto distribution using the STORS algorithm. It employs an optimized proposal distribution around the mode and Inverse Transform (IT) method for the tails.

Usage

srpareto_custom(n = 1, x = NULL)

Arguments

n

Integer, length 1. Number of samples to draw.

x

(optional) Numeric vector of length \(n\). If provided, this vector is overwritten in place to avoid any memory allocation.

Value

A numeric vector of length n containing random samples from the Pareto distribution. The shape and scale parameters are specified during the optimization process using srpareto_optimize().

NOTE: When the x parameter is specified, it is updated in-place with the simulation for performance reasons.

Details

The Pareto Distribution

The Pareto distribution has the probability density function (PDF): $$f(x | \alpha, \sigma) = \frac{\alpha \sigma^\alpha}{x^{\alpha + 1}}, \quad x \geq \sigma,$$ where:

\(\alpha\)

is the shape parameter (\(\alpha > 0\)), which determines the tail heaviness of the distribution.

\(\sigma\)

is the scale parameter (\(\sigma > 0\)), which determines the minimum possible value of \(x\).

The Pareto distribution is widely used in modelling phenomena with heavy tails, such as wealth distribution, insurance losses, and natural events.

This function samples from a proposal constructed using srpareto_optimize, employing the STORS algorithm.

By default, srpareto_custom() samples from the standard Pareto distribution with shape = 1 and rate = 1. The proposal distribution is pre-optimized at package load time using srpareto_optimize() with steps = 4091, creating a scalable proposal centred around the mode.

Note

This function is not scalable. Therefore, only the srpareto_custom() version is available, which requires the proposal to be pre-optimized using srpareto_optimize() before calling this function.

See also

srpareto_optimize to optimize the custom proposal.

Examples

# Generate 10 samples from Pareto Distribution
samples <- srpareto_custom(10)
print(samples)
#>  [1]  1.401960  1.316221 16.762458  1.015455  2.919894  1.789060  3.002464
#>  [8]  5.776708  1.781281  2.481220

# Generate 10 samples using a pre-allocated vector
x <- numeric(10)
srpareto_custom(10, x = x)
#>  [1] 1.205813 1.725548 2.533761 1.297318 2.319732 1.138127 1.119572 2.892254
#>  [9] 1.314239 2.271290
print(x)
#>  [1] 1.205813 1.725548 2.533761 1.297318 2.319732 1.138127 1.119572 2.892254
#>  [9] 1.314239 2.271290