How to solve for the parameters of the Gamma distribution given x for the 50th and 90th percentiles?

2.2k Views Asked by At

How can I solve for the parameters alpha and beta given that x = 20 is the 50th percentile, and x = 300 is the 90th percentile?

1

There are 1 best solutions below

0
On BEST ANSWER

I'll use the notation of the wikipedia article on the gamma distribution throughout.

Given that there's no simple closed form for the median of a gamma distribution, you'll want to do this numerically.

You can be smart about this, though. First, note that the ratio of the 90th to 50th percentiles of a gamma distribution depends only on the shape parameter $k$, not the scale parameter $\theta$. So we can ask: what is the shape parameter $k$ for which the 90th percentile divided by the 50th percentile is $300/20 = 15$? This is a couple lines in R:

f = function(k){qgamma(.9, k, 1)/qgamma(.5, k, 1)}
k0 = uniroot(function(k){f(k)-15}, c(0.1, 1))$root

The first line defines a function f which returns the 90th percentile of the $gamma(x,1)$ distribution divided by its 50th percentile. The second line finds a root of $f(x) - 15$ in the interval $[0.1, 1]$ and assigns it to k0.

This returns the root $\theta \approx 0.2672395$.

Now the median of a $Gamma(k_0, 1)$ random variable is given by qgamma(.5, k0, 1) in R and is equal to $m_0 = 0.05319006$. So to get the median equal to 20, you need a scale parameter $\theta_0 = 20/m_0 \approx 376.0101$.