0
$\begingroup$

Let $V=X+Y$ where $X$ and $Y$ are independent random variables, both normally distributed with $\mu=0$ and $\sigma=1$. I am interested in computing $E[X \mid V\geq c]$ where $c$ is an arbitrary constant. This is $$ E[X \mid V>c] = \frac{1}{1-\Phi_v(c)} \int_c^\infty \int_{-\infty}^{\infty} x \cdot f_X(x) \cdot f_Y(v-x) \quad dx ~dv $$ In Mathematica, with $c=0.5$, I am coding

1/(1 - CDF[NormalDistribution[0, 1], 0.5])
  Integrate[
  x PDF[NormalDistribution[0, 1], x] PDF[NormalDistribution[0, 1], 
    v - x], {x, -Infinity, Infinity}, {v, 0.5, Infinity}]

but this seems a very difficult problem for Mathematica to solve, taking a long time and sometimes not solving at all. If I use NIntegrate it is done instantly instead. My question is whether this is to be expected, or whether there is a way to do it symbolically in a more efficient way.

$\endgroup$
  • $\begingroup$ Did you try replacing 0.5 with 1/2? $\endgroup$ – Tim Laska Jan 21 at 23:57
  • $\begingroup$ @TimLaska Wow that makes a big difference! Can you explain me why? Also, in the symbolic answer I now get Erfc[-(1/(2 Sqrt[2]))]. How should I deal with it since I am interested in the actual numerical value? $\endgroup$ – mariodrumblue Jan 21 at 23:59
  • $\begingroup$ If you seek an analytical solution, sometimes it is better to provide rational fractions versus floating point numbers. It can change though, so you sometimes need to experiment. $\endgroup$ – Tim Laska Jan 22 at 0:03
  • $\begingroup$ To convert the exact analytic result to an approximate numeric result use result // N $\endgroup$ – Bob Hanlon Jan 22 at 0:57
1
$\begingroup$

Thanks to @AlexTourneau's slight modification to my approach exploiting the power of Mathematica:

Clear[x, y, c];
Expectation[x \[Conditioned] x + y > c, 
  {x \[Distributed] NormalDistribution[],
  y \[Distributed] NormalDistribution[]}]

$$\frac{e^{-\frac{c^2}{4}}}{\sqrt{\pi } \text{erfc}\left(\frac{c}{2}\right)}$$

$\endgroup$
  • $\begingroup$ Love the Expectation operator, which was unknown to me. This makes it a lot simple to write the code. It is also reasonably fast, however if I change the mean and standard deviations from a standard normal then it takes long or does not solve at all. For instance, this does not work Clear[x, y, c]; Expectation[ x \[Conditioned] x + y > 0.5, {x \[Distributed] NormalDistribution[1/2, 2], y \[Distributed] NormalDistribution[1/2, 2]}] $\endgroup$ – mariodrumblue Jan 22 at 1:19
  • $\begingroup$ Expectation[x \[Conditioned] x + y > c, {x \[Distributed] NormalDistribution[0, 1], y \[Distributed] NormalDistribution[2, 2]}] took 1.78 seconds (v. 11.3.0.0, Mac). and Expectation[ x \[Conditioned] x + y > 1/2, {x \[Distributed] NormalDistribution[0, 2], y \[Distributed] NormalDistribution[1/2, 2]}] to 0.5 seconds. Seems fast enough to me for a sophisticated calculation! $\endgroup$ – David G. Stork Jan 22 at 1:25
  • $\begingroup$ I am also on (v. 11.3.0.0, Mac) and yes with your parametrisation it works, but not with mine (i.e. when both variables have mean 0.5 and standard deviation 2). In other words, it seems that the speed and overall ability to solve depends on the parametrisation. That's a bit of an issue for me since I was planning to simulate the model (which makes use of that expectation) under different values of the parameters. $\endgroup$ – mariodrumblue Jan 22 at 1:33
  • $\begingroup$ @mariodrumblue: Experiment with exact and decimal numbers (e.g., $0.5$ versus $1/2$). $\endgroup$ – David G. Stork Jan 22 at 1:38
  • $\begingroup$ thanks David. I did and it did not make any difference. Also, Expectation[ x \[Conditioned] x + y > 1, {x \[Distributed] NormalDistribution[0.5, 2], y \[Distributed] NormalDistribution[0.5, 2]}] works, while changing the region over which the expectation is taken, such as Expectation[ x \[Conditioned] x + y > 0, {x \[Distributed] NormalDistribution[0.5, 2], y \[Distributed] NormalDistribution[0.5, 2]}] does not work. Am I missing something or is this because it is a very difficult problem that Mathematica struggles with? $\endgroup$ – mariodrumblue Jan 22 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.