Using the standard Cauchy distribution I am trying to compute E[√X | X ≥ 1] (I guess this is read "expected value of the square root of X given X is greater than or equal to 1") for a homework problem (we can use python/scipy). Intuitively, I think this value should be greater than 1 considering the square root of X is greater than 1 for X ≥ 1.
I am not sure if my intuition is incorrect or if I am doing something wrong to demonstrate this but the value I get from scipy using the code below is ~0.55.
The code I am using to get this is below
pdf = lambda x: 1 / (math.pi * (1 + x ** 2)) # standard Cauchy distribution continuous RV
class my_pdf(scipy.stats.rv_continuous):
def _pdf(self, x):
return 1 / (math.pi * (1 + x ** 2))
my_cv = my_pdf(name='my_pdf')
actual_expected_value = my_cv.expect(lambda t: math.sqrt(t), lb=1, ub=math.inf)
print(actual_expected_value) # gives ~0.55
Can someone help point me in the right direction? Am I doing something wrong with scipy or is my intuition incorrect? Thanks!
I don't speak python/scipy but upon attempting to interpret your code I see that you didn't account for the truncation of the Cauchy random variable. You need to divide by the probability that $X\geq1$ which is 1/4.
That means multiplying the number you got (0.55) by 4 which gets you 2.2. The answer is (using Mathematica)
$$\frac{\sqrt{2} \left(\pi +2 \coth ^{-1}\left(\sqrt{2}\right)\right)}{\pi }$$
which is approximately 2.20773.