0
$\begingroup$

I ran into a problem calculating the following expectation value:

smin = -6.; ds = 0.1; c = 6;
Expectation[x/c*e^((smin + (counter - 1)*ds)*x/c), x ≈ PoissonDistribution[c]]

It seems that Mathematica gets stuck for the value counter = 10, and I don't understand why. Could someone help?

$\endgroup$
  • $\begingroup$ I can get the generic Expectation[x/c Exp[a + b x /c], x \[Distributed] PoissonDistribution[n]]. $\endgroup$ – b.gates.you.know.what Feb 22 '17 at 14:56
  • $\begingroup$ How is that possible? On my laptop it doesn't work! $\endgroup$ – Francesco Coghi Feb 22 '17 at 15:09
  • $\begingroup$ Is it possible that you need \[Distributed] instead of ? (as @b.gatessucks suggests). Using that works for me on both versions 11.01 and 10.4.1 on Windows 7. $\endgroup$ – JimB Feb 22 '17 at 18:05
  • $\begingroup$ I don't think so, with Normal distribution works with ≈ $\endgroup$ – Francesco Coghi Feb 23 '17 at 8:29
2
$\begingroup$
$Version

(*  "11.0.1 for Mac OS X x86 (64-bit) (September 21, 2016)"  *)

smin = -6; ds = 1/10; c = 6; counter = 10;

As a workaround, you can either use NExpectation

NExpectation[x/c*E^((smin + (counter - 1)*ds)*x/c), 
 x \[Distributed] PoissonDistribution[c]]

(*  0.0137666  *)

Or take the Mean of the TransformedDistribution

Mean@TransformedDistribution[x/c*E^((smin + (counter - 1)*ds)*x/c), 
  x \[Distributed] PoissonDistribution[c]]

(*  E^(-(137/20) + 6/E^(17/20))  *)

% // N

(*  0.0137666  *)

EDIT: Works on an earlier version

$Version

(*  "10.4.1 for Mac OS X x86 (64-bit) (April 11, 2016)"  *)

smin = -6; ds = 1/10; c = 6; counter = 10;

Expectation[x/c*E^((smin + (counter - 1)*ds)*x/c), 
 x \[Distributed] PoissonDistribution[c]]

(*  E^(-(137/20) + 6/E^(17/20))  *)

% // N

(*  0.0137666  *)
$\endgroup$
  • $\begingroup$ I just tried with NExpectation and I get the same problem. Now I try with the second method you proposed. Thanks $\endgroup$ – Francesco Coghi Feb 22 '17 at 15:10
  • $\begingroup$ @FrancescoCoghi - what version and OS are you using? $\endgroup$ – Bob Hanlon Feb 22 '17 at 15:15
  • $\begingroup$ I'm on windows10 with Mathematica 10.4 $\endgroup$ – Francesco Coghi Feb 22 '17 at 15:20

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.