# Conditional expectation

#### bizan

##### New Member
Good afternoon, I have to calculate the expected value of a logistic distribution given that the values are above a given constant (lets say 0). So far I have done it numerically by programming a generator of random numbers coming from a logistic distribution and then taking the average of those above 0.

I would like to know if it is possible to have something more accurate.

The expected value is the integral between -inf + inf of x pdf(x)dx. The conditional expected value would be the same integral between 0 and +inf of pdf(x|y)dx ?

Is this pdf possible to calculate?

Thank you very much

Last edited:

#### BGM

##### TS Contributor
You should be looking for the (pdf of) truncated distribution. Loosely speaking it is just like you normalize a part of the pdf to 1 by dividing the corresponding probability (area under the pdf).

You may think like this: consider the CDF of the conditional random variable $$X|X > a$$

$$F_{X|X > a}(x) = \Pr\{X \leq x|X > a\} = \frac {\Pr\{X \leq x, X > a\}} {\Pr\{X > a\}}$$

It is obvious that when $$x < a$$, the probability in the numerator vanish, i.e. it is not the support of the conditional random variable. When $$x \geq a$$, we can further simplify to

$$= \frac {\Pr\{X \leq x\} - \Pr\{X \leq a\}} {\Pr\{X > a\}} = \frac {F_X(x) - F_X(a)} {1 - F_X(a)}$$

where $$F_X$$ is the unconditional CDF of $$X$$. Now differentiate with respect to $$x$$, we obtain the conditional pdf:

$$f_{X|X > a}(x) = \frac {f_X(x)} {1 - F_X(a)}, x > a$$ and 0 otherwise.

After writing this expression, the required conditional expectation is

$$E[X|X > a] = \int_{-\infty}^{+\infty} x f_{X|X > a}(x) dx = \int_a^{+\infty} x \frac {f_X(x)} {1 - F_X(a)} dx$$