7
$\begingroup$

Let $X \sim Gamma(3,3)$ and $Y \sim Exp(1)$.

How do I calculate $P(X>Y)$?

I believe I rewrite it as $P(X-Y>0)$ but I am unsure how to calculate $X-Y$ for two different distributions?

$\endgroup$
4
  • 1
    $\begingroup$ Possible duplicate of Difference of Gamma random variables $\endgroup$ Commented Mar 1, 2017 at 21:51
  • $\begingroup$ Here is an article dealing with your problem. I believe it is possible to obtain a close-form density for $X-Y$ in your case. Observe that a standard exponential distribution is a $\mathrm{Gamma}(1, 1)$ distribution. $\endgroup$ Commented Mar 1, 2017 at 21:55
  • 2
    $\begingroup$ @COOL Although that approach will work, it seems like an overly complicated way to find a single probability: we don't need to figure out the entire distribution of the difference. $\endgroup$
    – whuber
    Commented Mar 1, 2017 at 22:29
  • $\begingroup$ The crucial assumption of independence of $X$ and $Y$ is missing. $\endgroup$ Commented Feb 5, 2020 at 18:30

3 Answers 3

10
$\begingroup$

If $X$ has density function $\lambda \frac{(\lambda x)^2}{\Gamma(3)}\exp(-\lambda x)\mathbf 1_{\{x\colon x > 0\}}$ and independent $Y$ has density function $\exp(-y)\mathbf 1_{\{y\colon x > 0\}}$, then \begin{align} P\{X < Y\} &= \int_{0}^\infty \lambda \frac{(\lambda x)^2}{\Gamma(3)}\exp(-\lambda x) \int_{x}^\infty \exp(-y)\, \mathrm dy \, \mathrm dx\\ &= \int_{0}^\infty \lambda \frac{(\lambda x)^2}{\Gamma(3)}\exp(-(\lambda+1) x)\, \mathrm dx\\ &= \left(\frac{\lambda}{\lambda+1}\right)^3\int_{0}^\infty (\lambda+1) \frac{((\lambda+1) x)^2}{\Gamma(3)}\exp(-(\lambda+1) x)\, \mathrm dx\\ &= \left(\frac{\lambda}{\lambda+1}\right)^3. \end{align}


Consider also a Poisson process with arrival rate $\lambda+1$. We can decompose this process into two independent Poisson subprocesses $\mathcal X$ and $\mathcal Y$ of rates $\lambda$ and $1$ respectively by labeling each arrival as belonging either to the $\mathcal X$ process (with probability $\frac{\lambda}{\lambda+1}$) or to the $\mathcal Y$ process (with probability $\frac{1}{\lambda+1}$), with each label being chosen independently of all other labels. Then, $X$ can be taken to be the time of the third arrival (after $t = 0$) in the $\mathcal X$ subprocess while $Y$ is the time of the first arrival (after $t = 0$) in the $\mathcal Y$ subprocess. With this interpretation, $X < Y$ is just the event that the first three arrivals after $t=0$ were all labeled as belonging to the $\mathcal X$ subprocess, and this event has probability $\displaystyle \left(\frac{\lambda}{\lambda+1}\right)^3$. Look, Ma! No integrals were computed in arriving at the answer!

$\endgroup$
7
$\begingroup$

There is a relationship between gamma and beta random variables that leads to a general expression for $P[X>Y]$ for any two independent gamma random variables.

If $X \sim \rm{Gamma}(\alpha_1,\beta_1)$ and $Y \sim \rm{Gamma}(\alpha_2,\beta_2),$ where $\alpha$ is the shape parameter, $\beta$ is the scale parameter, and the mean is $\alpha \beta,$ then

$$P[X>Y] = H_{\alpha_2,\alpha_1} \left( \frac{\beta_1}{\beta_1+\beta_2} \right),$$

where $H$ is the cumulative distribution function of a beta random variable. In your case I calculate $P[X>Y]=0.984375$

If you have used a different parameterization of the gamma distribution, this will need to be adjusted.

Here is the development. We can construct $\beta_1Y \sim \rm{Gamma}(\alpha_2,\beta_1\beta_2)$ and $\beta_2X \sim \rm{Gamma} (\alpha_1,\beta_1 \beta_2).$ Now consider $$W = \frac{\beta_1Y}{\beta_1Y+\beta_2X}$$

It is known (see https://en.wikipedia.org/wiki/Gamma_distribution, Related Distributions and Properties Section) that $W$ has a beta distribution with first shape parameter of $\alpha_2$ and second shape parameter of $\alpha_1.$

So then $$P \left[ W = \frac{\beta_1Y}{\beta_1Y+\beta_2X}<\frac{\beta_1}{\beta_1+\beta_2} \right]=H_{\alpha_2,\alpha_1} \left( \frac{\beta_1}{\beta_1+\beta_2} \right),$$

where $H$ is the cumulative distribution function of a beta random variable.

Taking reciprocals and simplifying, $$P \left[ W = \frac{\beta_1Y}{\beta_1Y+\beta_2X}<\frac{\beta_1}{\beta_1+\beta_2} \right]=P \left[ \frac{\beta_1Y+\beta_2X}{\beta_1Y} > \frac{\beta_1+\beta_2}{\beta_1} \right]$$

$$ = P \left[ 1 + \frac{\beta_2X}{\beta_1Y}>1+\frac{\beta_2}{\beta_1} \right]=P \left[ \frac{X}{Y} >1 \right] =P \left[ X>Y \right] =H_{\alpha_2,\alpha_1} \left( \frac{\beta_1}{\beta_1+\beta_2} \right)$$

$\endgroup$
5
  • 1
    $\begingroup$ Could you demonstrate this result or cite an accessible reference? I'm having a hard time seeing why it should be true. For instance, let $\alpha_1=\alpha_2=\beta_2=1$ and consider what happens as $\beta_1$ grows large. The right hand side approaches $F_{1,1}(1) = 0.391826\ldots$ from below, whereas the left hand side ought to approach $1$. $\endgroup$
    – whuber
    Commented Mar 2, 2017 at 0:34
  • 1
    $\begingroup$ Where do you get $F_{1,1}(1)=0.391826$? As stated, $F$ is the cdf of a beta random variable. So $F_{1,1}(1)=1.$ I see how the notation could be misleading, though. I will add some development to show the result if I can make time. $\endgroup$
    – soakley
    Commented Mar 2, 2017 at 14:38
  • 1
    $\begingroup$ Sorry, I overlooked the "beta" part and assumed you were referring to the (closely related) F ratio distribution! Thank you for explaining. $\endgroup$
    – whuber
    Commented Mar 2, 2017 at 15:02
  • $\begingroup$ @whuber soakley I believe this goes something like: $P[X>Y] = P[Y^* < \frac{\beta_2}{\beta_1} X^*]$ where $X^* \sim \rm{Gamma}(\alpha_1,1)$ and $Y^* \sim \rm{Gamma}(\alpha_2,1)$ are unit scaled versions of $X$ and $Y$. Using $\frac{Y^*}{Y^*+X^*} \sim \rm{Beta}(\alpha_2,\alpha_1)$ (Wikipedia), and noting that $P[\frac{Y^*}{Y^*+X^*} < c] = P[Y^* < \frac{c}{1-c}X^*]$, we set $\frac{c}{1-c} = \frac{\beta_2}{\beta_1}$ giving $c = \frac{\beta_1}{\beta_1 + \beta_2}$. $\endgroup$
    – A. Webb
    Commented Mar 2, 2017 at 18:20
  • $\begingroup$ Yes, I have added the development and changed the beta cdf to be designated as $H$ in order to avoid confusion with an $F$ distribution. $\endgroup$
    – soakley
    Commented Mar 2, 2017 at 18:26
2
$\begingroup$

The rote way to compute $P[Y>X]$ is by double integral

$$\int_0^\infty f_X(x) dx \int_x^\infty f_Y(y) dy $$

Where the inner integral may be recognized as the survival function of $Y$, an exponential with parameter $\lambda=1$, at $x$, equal to $e^{-x}$. Then the remaining integral

$$\int_0^\infty e^{-x} f_X(x) dx $$

may be recognized as the moment generating function of $X$ evaluated at $-1$. The MGF of a $\rm{Gamma}$ is $(1-\theta t)^{-k}$, which for $\theta = 3, k=3, t=-1$ is

$$(1+3)^{-3} = 0.015625$$

The question was for $P[X>Y] = 1-P[Y>X]$, so we want

$$1-(1+3)^{-3} = 1-0.015625 = 0.984375$$

which agrees with soakley's answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.