# Simulate Lomax distribution

I want to simulate the Lomax / Pareto type 2 distribution from a standard uniform distribution in python. I managed to transform it into a Pareto distribution, but I'm not sure how to transform it from there into the Lomax distribution

    class continous:
def uniform(self, **kwargs):
return uniform(**kwargs)

def lomax(self, theta,alpha,size):
u = self.uniform(size=size)
x=(theta)*(1-u)**(-1/alpha)
return x

x=continous().lomax(theta=5, alpha=10, size=1000)



Simply invert the distribution function. It's efficient.

Here are the details.

A standardized Lomax distribution with shape parameter $$\alpha\gt 0$$ has distribution function (CDF)

$$F(z;\alpha) = 1 - \frac{1}{(1+z)^{\alpha}},\quad x \ge 0.$$

Its quantile function is thereby straightforward to find as

$$F^{-1}(q;\alpha) = \left(1 - q\right)^{-1/\alpha}-1,\quad 0 \lt q \le 1$$

(and $$F^{-1}(0;\alpha) = 0$$).

Applying this function to a uniform random variable $$U$$ (supported between $$0$$ and $$1$$) generates a standard Lomax variate $$Z,$$ because for any $$z\gt 0,$$ the definitions (of CDF and uniform distribution) give

$$\Pr(Z \le z) = \Pr(F^{-1}(U;\alpha)\le z) = \Pr(U \le F(z;\alpha)) = F(z;\alpha),$$

showing that such a $$Z$$ has the desired Lomax distribution.

More generally, the Lomax distribution family includes a scale factor $$\lambda\gt 0.$$ This just means that to generate such a variable $$X$$, generate $$Z$$ from the corresponding standardized Lomax distribution and multiply that result by $$\lambda.$$ Thus, to generate random variates for given $$\alpha\gt 0$$ and $$\lambda \gt 0,$$

Generate a uniform variate $$U$$ (between $$0$$ and $$1$$) and set $$X = \lambda\left(\left(1 - U\right)^{-1/\alpha}-1\right).$$