# Calculating Probability of a given X range if X is a continuous random variable with a given PDF.

This question was given to me as a review for an upcoming exam.

Find $$P(2 \leq X \leq 3)$$ if $$X$$ is a continous random variable with pdf: $$f_X(x) = \begin{cases} xe^{-x} & x\geq 0 \\ 0 & x \lt 0 \end{cases}$$ My work: $$P(2 \leq X \leq 3) = \int_{2}^{3}xe^{-x}dx$$

Integration by parts:

$$u=x,u'=1,v'=e^{-x},v=-e^{-x}$$

$$\int_{2}^{3}xe^{-x} dx = -xe^{-x}\Big|^3_2-\int_{2}^{3}-e^{-x}dx\\ =\frac{-4}{e^3} + \frac{3}{e^2} \approx 0.2069$$

Did I miss anything or do something incorrectly?

Also, I had a quick question regarding a different case, let's say problem was asking for $$P(-1 \leq X \leq 3)$$ instead, would we do this instead?: $$P(-1 \leq X \leq 3)= \int_{-1}^{0}0 dx + \int_0^3xe^{-x}dx$$

Obviously the left integral will be 0 in this case, I'm just wondering if we split up the integrals with addition if the range we are looking for is in two different domains of the PDF.

• To your quick question -- yes – Minus One-Twelfth Mar 23 at 1:55
• Both parts are correct. – Kavi Rama Murthy Mar 23 at 5:26
• Perhaps see Wikipedia. This is the PDF of a RV with dist'n $\mathsf{Gamma}(shape=2, rate=1).$ In R: code diff(pgamma(c(2,3), 2, 1)) returns 0.2068576. Also, pgamma(3, 2, 1) returns 0.8008517. [pgamma is the CDF of a gamma distribution.] Because the support is the positive half line, you could just find $P(0 \le X \le 3).$ – BruceET Mar 23 at 17:07