I am trying to generate random numbers using Monte Carlo simulation from Pareto distribution using R. But I am not able to find the codes for the same. It would be very helpful if someone could share some link for the R codes or some reading material.
1 Answer
According to Wikipedia, the cumulative density function (CDF) of a Pareto distribution has the form
$$F(x;x_m,\alpha) = 1 - \left(\frac{x_m}{x}\right)^\alpha$$
for positive numbers $x_m$ and $\alpha.$
This is simple to invert because the rules of algebra permit us to solve the equation $u=F(x;x_m,\alpha)$ as
$$x = \frac{x_m}{(1-u)^{1/\alpha}}.$$
Because $F$ is differentiable in $x,$ it is a continuous distribution, whence by letting $U$ have a uniform distribution on the interval $[0,1)$ and substituting it for $u,$ we see that the random variable
$$X = \frac{x_m}{(1-U)^{1/\alpha}}$$
has the desired Pareto distribution. (This is an application of the Probability Integral Transform.) Note that since $U$ and $1-U$ have the same distribution, the denominator may be simplified to $U.$
The R
function runif
draws uniform random variates on the interval $[0,1).$ Thus, a direct R
implementation is
rpareto <- function(n, alpha, x.m) x.m / runif(n)^(1/alpha)
So little computation is needed that we may conclude this is an efficient implementation.
rpareto
function, which let's you simulate samples from the pareto distribution. Just do a google search for this function. $\endgroup$