# Probability between two values of a gamma distribution

I am trying to solve a problem where I have a random variable X that follows a gamma distribution of $$\Gamma(\theta = 5, \alpha = 4)$$.

I am trying to find the probability of $$P(10 \leq X \leq 30)$$. Obviously, if this was a normal distribution it would be simple, but I do not know how to approach this problem currently. I am confused on if how to convert it to a $$\chi^2$$ and how that helps me solve this problem. Thank you

• You would have to specify the exact pdf of $X$. – StubbornAtom Mar 26 at 7:47
• The pdf of X just follows the gamma distribution no? So it would be$\int_{-\infty}^{\infty} \frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha-1}e^{\frac{-x}{\theta}} dx$ and I know that for P(X > a) is just $\int_{a}^{\infty} \frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha-1}e^{\frac{-x}{\theta}} dx$ – air bmx Mar 26 at 8:26

According to your comment $$\alpha=4$$ is a shape parameter and $$\theta = 5$$ is a scale parameter. This problem is trivial to solve in R, where the second parameter is $$\lambda = 1/\theta = .2$$ (a rate parameter). In R, $$\texttt{diff(pgamma(c(10,30), 4, .2))}$$ returns $$0.7059196.$$

Because the shape parameter is an integer, you can indeed express this problem in terms of a chi-squared distribution. Then, using printed tables of chi-squared distributions, you might find entries that give you a numerical solution. (Ultimately, such problems are often solved by computational methods--which, of course, were required to make chi-squared tables.)

I guess the intent of this exercise is for you understand the connection between the gamma family of distributions and its chi-squared subfamily. Perhaps comparing the general PDFs of the two will show you the relationship.

Here is a graph of the relevant density function with dotted lines bounding the area you need to compute. Notes: (1) See Wikipedia discussions of 'gamma distribution' and 'chi-squared distribution' if your textbook doesn't discuss, shape, scale, rate, and degrees-of-freedom parameters.

(2) This integral can be evaluated by numerical integration. The method is to imitate a finite version of the definition of the Riemann integral: Approximate the desired area by a suitably large number of tall, thin rectangles and sum their areas.

(3) Essentially, method (2) is implemented in the 'integrate' function of R:

integrand = function(x){dgamma(x, 4, .2)}
integrate(integrand, 10, 30)
0.7059196 with absolute error < 7.8e-15


(4) Using one of several Monte Carlo methods, one may simulate a large sample from $$\mathsf{Gamma}(4, .2)$$ and look at the proportion of the values that lie between 10 and 30. This gives a reasonably good approximation (about two places in the example below):

set.seed(2020);  x = rgamma(10^6, 4, .2)
mean(x>10 & x<30)  # 'mean' of logical vector is its...
 0.705994       # ... proportion of TRUE's
2*sd(x>10 & x < 30)/10^3
 0.0009111897   # aprx 95% margin of sim error

• I see, thank you for giving a proper explanation as well and information as well regarding the monte carlo method. Fortunately I was able to solve this problem mathematically by bounding the integral twice $$P(10 \leq X \leq 30) = \int_{10}^{30} \frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha-1}e^{\frac{-x}{\theta}}dx = \frac{1}{3!\cdot 5^4} \int_{10}^{30}x^3\cdot e^{\frac{-x}{5}}dx$$ = 0.70591 – air bmx Mar 27 at 2:29

I hope you understand that this type of approaches really become to stressful and hard to compute by hand although it’s really hard because the integral cannot be made by normal ways, it requieres numerical approaches So try to take a time to learn some kind of computational stuff like R. But if you require the solution by handwriting hold on. I’m working on it

• Thank you very much! Fortunately, I solved the question myself. For some reason it didn't hit me that a double bound would lead to $$P(10 \leq X \leq 30) = \int_{10}^{30} \frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha-1}e^{\frac{-x}{\theta}}dx = \frac{1}{3!\cdot 5^4} \int_{10}^{30}x^3\cdot e^{\frac{-x}{5}}dx$$ = 0.70591 – air bmx Mar 27 at 2:27
• Nice! You can almost always make the integral of almost every Probability of the type P(a<x<b) just as long the integral is convergent or it could be expressed in terms of elemental functions. In this case just the Gamma Function times the constant that makes the integral a distribution to integrate 1 over the interval (0,∞) – Alonso Rangel Mar 27 at 2:32