Random variable with defined density function in R

104 Views Asked by At

Let $X$ be a random variable with density function $$ f(x)= \begin{cases} x^{-2} &\text{if } x>1, \\ 0 &\text{if } x<1. \end{cases} $$ Calculate $P(X>3 \mid X > 2)$.

I wonder if is possible to do it with R (the software package) and how I can do it.

1

There are 1 best solutions below

0
On BEST ANSWER

Here you have to use the Bayes theorem:

$$P(X> 3\mid X> 2)=\frac{P(X>3 \cap X>2) }{P(X>2)}=\frac{P(X>3 ) }{P(X>2)}$$

$$\frac{\int_3^{\infty} \frac1{x^2}\, dx }{\int_2^{\infty} \frac1{x^2}\, dx }=\frac{\left[ -\frac1x \right]_3^{\infty}}{\left[ -\frac1x \right]_2^{\infty}}=\frac{0-(-\frac13)}{0-(-\frac12)}=\frac{\frac13}{\frac12}=\frac23$$

If you want to use R then see here how to use it. For instance, the numerator in R is

f <- function(x) {1/x^2}

integrate(f, lower = 3, upper = Inf)