9
$\begingroup$

fixed in 10.1 (windows)


Binormal and Multinormal can both be used to represent normal random variables:

S = {{2, 0.5}, {0.5, 1}};
Covariance[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]
Covariance[MultinormalDistribution[{0, 0}, S]]
Mean[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]
Mean[MultinormalDistribution[{0, 0}, S]]

Results in

{{2, 0.5}, {0.5, 1}}
{{2, 0.5}, {0.5, 1}}
{0, 0}
{0, 0}

But,

NExpectation[x*y, {x, y} \[Distributed] BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]
NExpectation[x*y, {x, y} \[Distributed] MultinormalDistribution[{0, 0}, S]]

yields

0.5
0.25

What am I missing?

$\endgroup$
  • $\begingroup$ I get 0.5 and 0.5 (Mathematica 10.0.0, Windows 8.1) Did S accidentally get redefined before your second evaluation? $\endgroup$ – 2012rcampion Mar 15 '15 at 19:38
  • $\begingroup$ I double-checked, but no. I opened a new notebook and ran only the code I posted, along with << NumericalCalculus` I'm running Linux. Is it possible to have differences between platforms? $\endgroup$ – NickJ Mar 15 '15 at 19:41
  • $\begingroup$ I get 0.5 and 0.25 using v10.0.2 on a Mac; however. Expectation rather than NExpectation gives 0.5 for both distributions. $\endgroup$ – Bob Hanlon Mar 15 '15 at 20:07
  • $\begingroup$ I get .5 for both , mma 9.0.1 $\endgroup$ – ciao Mar 15 '15 at 20:27
  • 1
    $\begingroup$ I can confirm that on win8.1 MMA 8.04, 9 and 10.0.2 yield {0.5,0.5}, {0.5,0.5} and {0.5,0.25}, respectively. Looks like a bug introduced in v10 after 10.0.0. Could you report this to support@wolfram.com? $\endgroup$ – Sjoerd C. de Vries Mar 15 '15 at 22:07
6
$\begingroup$

In version 10.0.2 Mathematica is using an incorrect standardization rule

Statistics`Library`StandardizationRules[{x, y},                    
  MultinormalDistribution[{0, 0}, {{2, 0.5}, {0.5, 1}}]]
{{x -> x/Sqrt[2], y -> y}, 
 MultinormalDistribution[{0, 0}, {{1, 0.353553}, {0.353553, 1}}]}

This is incorrect as

Expectation[(x y)/Sqrt[2], 
 {x, y} \[Distributed] MultinormalDistribution[{0, 0}, {{1, 0.35355339059327373`}, {0.35355339059327373`, 1}}]]

0.25

shows.

The nonnumerical expectation

Expectation[x*y, {x, y} \[Distributed] MultinormalDistribution[{0, 0}, S]]

0.5

gives a correct result.

Using the option Method -> "MonteCarlo" gives a correct approximation

NExpectation[x*y, {x, y} \[Distributed] MultinormalDistribution[{0, 0}, S], 
  Method -> "MonteCarlo"]

0.498123

Using NIntegrate directly gives a correct result

NIntegrate[
 x*y PDF[MultinormalDistribution[{0, 0}, S], {x, y}], 
 {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]

0.5


Symbolic:

Statistics`Library`StandardizationRules[{x, y}, 
 MultinormalDistribution[{0, 0}, {{s11, s12}, {s21, s22}}]]
{{x -> x/Sqrt[s11], y -> y/Sqrt[s22]}, 
 MultinormalDistribution[{0, 0}, 
  {{1, 1/2 (s12/(Sqrt[s11] Sqrt[s22]) + s21/(Sqrt[s11] Sqrt[s22]))}, 
   {1/2 (s12/(Sqrt[s11] Sqrt[s22]) + s21/(Sqrt[s11] Sqrt[s22])), 1}}]}
Expectation[
 x/Sqrt[s11]*y/Sqrt[s22], 
 {x, y} \[Distributed] MultinormalDistribution[{0, 0}, 
  {{1, 1/2 (s12/(Sqrt[s11] Sqrt[s22]) + s21/(Sqrt[s11] Sqrt[s22]))}, 
   {1/2 (s12/(Sqrt[s11] Sqrt[s22]) + s21/(Sqrt[s11] Sqrt[s22])), 1}}]]

(s12 + s21)/(2 s11 s22)

But

Expectation[
 x*y, 
 {x, y} \[Distributed] MultinormalDistribution[{0, 0}, {{s11, s12}, {s21, s22}}]]

s21

$\endgroup$
1
$\begingroup$

Fixed in 10.1 (windows)

Mathematica graphics


Mathematica graphics

code

S = {{2, 0.5}, {0.5, 1}};
Covariance[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]];
Covariance[MultinormalDistribution[{0, 0}, S]];
Mean[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]];
Mean[MultinormalDistribution[{0, 0}, S]];
NExpectation[x*y, {x, y} \[Distributed] BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]
NExpectation[x*y, {x, y} \[Distributed] MultinormalDistribution[{0, 0}, S]]
$\endgroup$

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.