# Ratio of Gamma distributed variables with different parameters

I encounter a problem which I thought I can handle, however, I struggle a lot with finding a solution:

The following setting applies: I want to compute the posterior probability of an event, which is defined as the fraction of two distinct arrival rates of, lets say, some agents. So I define as priors for the arrival rates $\mu$ and $\varepsilon$ Gamma distributions with parameters $\mu\sim G(\alpha_\mu,\beta)$ and $\varepsilon\sim G(\alpha_\varepsilon,\beta)$.

The event I am interested in depends on some constant $1>c>0$ and is characterized by $$P = \frac{c(\varepsilon+\mu)}{\varepsilon + c\mu}.$$ Well, the nominator takes the form $c(\varepsilon+\mu) \sim G(\alpha_\mu + \alpha_\varepsilon, \frac{\beta}{c})$, however, as the two parts in the denominator do not have the identical scale parameter I cannot simply identify the distribution of $P$ as a beta distribution as would be the case given I would simply compute $\frac{x}{y+x}$ with $x\sim G(\alpha_1,\theta), y\sim G(\alpha_2,\theta)$.

Is there any way to overcome this problem and to find the probability distribution of $P$? Or, is there another distribution which would give me some closed form solutions for $P$?

• Algebra shows that $$P = 1 - \frac{1-c}{1 + c\frac{\mu}{\epsilon}}.$$ The ratio $\mu/\epsilon$ is a multiple of an $F$ distribution. That's probably as far as you'll get in simplifying things, but it gives you a direct, simple way to compute the CDF and inverse CDF of $P$. (Notice that $\beta$ plays no role; it drops out of the ratio that defines $P$.)
– whuber
Jul 14, 2016 at 21:21
• Great, thank you @whuber ! Do you have any idea whether I can say something about the moments of this representation? Jul 15, 2016 at 8:41
• Use the CDF directly.
– whuber
Jul 15, 2016 at 13:20
• @whuber What is two gamma variate are not independent with weak correlation (say 0.3)? Is the ratio still follow F? Oct 4, 2018 at 14:56
• @Over probably not. You can see this by considering an extreme case where the correlation is nearly $1:$ that implies the ratio will be closely concentrated around $1$ itself, far more so than any $F$ distribution whose degrees of freedom are anywhere close to the DFs of the Gamma distributions.
– whuber
Oct 4, 2018 at 17:05

You could think of approximating it using Kernel Density Estimation. Since you can easily simulate gamma variates, then you can easily simulate from P. Using a simulated sample, you can then construct a nonparametric estimator of this density. The following R code shows the approximation using 100,000 simulations (quite a few).

# Parameters
a.mu = 5
a.eps = 5
beta = 5
c = 0.5
# Number of simulations
N = 100000

# Simulated P
mu = rgamma(N,a.mu,beta)
eps = rgamma(N,a.eps,beta)
P.sim = c*(eps+mu)/(eps+c*mu)

# Bandwidth
h = bw.nrd0(P.sim)

# Kernel density estimator
denP = Vectorize(function(t)  mean(dnorm(t-P.sim,0,h)) )

# Fit
hist(P.sim,probability=T,ylim=c(0,6))