# Generating random numbers from Dagum or Generalized Extreme Values Distributions

I need in particular to generate random numbers from a Four parameters Dagum distribution: http://www.mathwave.com/help/easyfit/html/analyses/distributions/dagum.html

And from the Generalized Extreme Value distribution http://www.mathwave.com/help/easyfit/html/analyses/distributions/gen_extreme.html

I can't find the formula/algorithm anywhere. I can't imagine that this is not solved quite often. I find it quite hard to do the inverse CDF of the generalized extreme value distribution... but maybe I'm overthinking it?

It's not that hard, but you need to be careful with the details and go in small steps, as usual.

For the Dagum distribution, we replace $F(x)$ with $U$, a Uniform$(0,1)$ variate, and work through the algebra, two (or so) steps at a time:

$$U = \left (1 + \left (\frac{x-\gamma}{\beta} \right )^{-\alpha} \right)^{-k}$$ $$U^{-1/k}-1 = \left(\frac{x-\gamma}{\beta}\right)^{-\alpha}$$ $$\beta \left(U^{-1/k}-1\right)^{-1/\alpha} = x - \gamma$$ $$x = \gamma + \beta \left(U^{-1/k}-1\right)^{-1/\alpha}$$

For the Generalized Extreme Value distribution, we have, for $k > 0$,:

$$U = \exp\left\{-(1+kz)^{-1/k}\right\}$$ $$(-\ln U)^{-k} = 1+kz$$ $$\frac{(-\ln U)^{-k}-1}{k} = z = \frac{x-\mu}{\sigma}$$ $$x = \sigma\frac{(-\ln U)^{-k}-1}{k}+\mu$$

When $k = 0$, we have, jumping ahead a bit,:

$$\ln (-\ln U) = -z$$ $$-\sigma(\ln (-\ln U)) + \mu = x$$