# Multiplying two Gamma distributions over the same variable

I am looking at a software library where there is a function that multiplies two Gamma distributions defined over the same random variable. So, it is basically multiplying two Gamma densities with shape and rate parameters.

So, the Gamma distribution parameterised by the shape and rate parameters is given as:

$$D(x; \alpha, \beta) = \frac{\beta^{\alpha} x^{\alpha-1} e^{-\beta x}}{\Gamma(\alpha)}$$

where $\alpha$ is the shape parameter and $\beta$ is the rate parameter and $\Gamma$ is the Gamma function defined as $\Gamma(\alpha) = \int_{0}^{\infty} x^{\alpha-1} e^{-x} dx$.

Do, I want to get an expression for the product of $D(x; \alpha_0, \beta_0)$ and $D(x; \alpha_1, \beta_1)$. Apparently, this should be another Gamma distribution and according to this software implementation, the shape and rate parameters for this new Gamma distribution should be: $\alpha_{new} = \alpha_0 + \alpha_1 - 1$ and $\beta_{new} = \beta_0 + \beta_1$.

Now, apparently this should be simple algebra but I have been unsuccessfully been trying to formulate this product in a way that I can equate the terms with the expression for the Gamma distribution that would arrive at this result.

-
math.stackexchange.com/questions/203621/… this may help you – dato datuashvili Feb 20 '14 at 19:21
My case is slightly different as the random variable over which these distributions are defined are the same. So, $x$ is the RV and it is the same in both the expressions. Hence, it is less complicated but I still cannot see how the authors came to that expression. The author, in question, is very well known and accomplished, so it is likely I have not figured it out. – Luca Feb 20 '14 at 19:29
there exist another definition of gamma function,so you may use elementary algebraic property like $e^{x+y}=e^{x}*e^{y}$ and so on – dato datuashvili Feb 20 '14 at 19:31
Thanks for the reply Dato. Do you have any reference for this definition? That would be very useful. I tried finding it but do not know which one you are talking about. – Luca Feb 20 '14 at 21:29

The product of two gamma densities on the same variable is proportional to another gamma density ... as long as the sum of the two shape parameters in the product is > 1. When that's not true, it's not the case that the product is proportional to a density.

consider:

$$g(x) = f(x;\alpha_1,\beta_1)\cdot f(x;\alpha_2,\beta_2)$$

where $f(x;\alpha,\beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1} e^{- \beta x }\,,\quad x>0,\,\alpha,\beta>0$

$$g(x) = \frac{\beta_1^{\alpha_1}}{\Gamma(\alpha_1)} x^{\alpha_1-1} e^{- \beta_1 x }\frac{\beta_2^{\alpha_2}}{\Gamma(\alpha_2)} x^{\alpha_2-1} e^{- \beta_2 x }$$

$$\quad\quad = \frac{\beta_1^{\alpha_1}}{\Gamma(\alpha_1)}\frac{\beta_2^{\alpha_2}}{\Gamma(\alpha_2)} x^{\alpha_1-1}x^{\alpha_2-1} e^{- \beta_1 x }e^{- \beta_2 x }$$

$$\quad\quad = \frac{\beta_1^{\alpha_1}}{\Gamma(\alpha_1)}\frac{\beta_2^{\alpha_2}}{\Gamma(\alpha_2)} x^{(\alpha_1+\alpha_2-1)-1} e^{- (\beta_1+ \beta_2) x }$$

Clearly, for that to be proportional to a $\text{gamma}(\alpha_1+\alpha_2-1,\beta_1+ \beta_2)$ density, its parameters must obey the constraints on the parameters (i.e. $\alpha_1+\alpha_2-1>0$, or $\alpha_1+\alpha_2>1$).

What happens when it's not the case that $\alpha_1+\alpha_2-1>0$?

To simplify things consider $\beta_1+ \beta_2=1$, and let $\delta=\alpha_1+\alpha_2-1$. The gamma pdf is:

$$\frac{1}{\Gamma(\delta)} x^{\delta-1} e^{- x }\,,\quad x>0\,.$$

Now in the case where $\delta\leq 0$, the integral that defines $\Gamma(\delta)$ doesn't converge (though the function is generally extended to negative values via analytic continuation, that's no longer the value of the integral).

Which is to say, we no longer have something prortional to a valid pdf.

When $\alpha_1+\alpha_2>1$, the multiplicative constant out the front of the gamma density is

$$\frac{\beta_1^{\alpha_1}\beta_2^{\alpha_2}}{(\beta_1+\beta_2)^{\alpha_1+\alpha_2-1}}\frac{\Gamma(\alpha_1+\alpha_2-1)}{\Gamma(\alpha_1)\Gamma(\alpha_2)}\,.$$

which can be simplified a little, but which I won't pursue further here as I don't think that's what you're after.

-
Thanks for the answer! One thing that bothers me is the normalizer. Clearly it is not of the form $\a^{\b}$ where $a = \beta_1 + \beta_2$ and $b = \alpha_1 + \alpha_2 - 1$. Same goes for the multiplication of these $\Gamma$ functions. So, it is proportional to a Gamma distribution but the constant of proportionality does not match... – Luca Feb 21 '14 at 11:22
@Luca Right - the product of gamma densities isn't a density, but it's proportional to one (given the restrictions mentioned). Why would that bother you? It's generally not the case that the product of densities is a density, so I see no reason to expect it to hold here. Does it also bother you that the product of two normal densities isn't a normal density (it's proportional to one, as here)? – Glen_b Nov 1 '14 at 1:52
You are right Glen. I am still getting over my hangups about these things :-) many thanks again for all your help. – Luca Nov 1 '14 at 13:32