New in Wolfram
Mathematica
8: Probability and Statistics Solvers and Properties
◄
previous
|
next
►
Core Algorithms
Compute the Expectation of an Expression
Compute the expectations of expressions in parametric, nonparametric, derived, or formula distributions.
In[1]:=
X
expectations = {HoldForm[ Expectation[E^(2 x), x \[Distributed] PoissonDistribution[\[Lambda]]]], HoldForm[ Expectation[(x - 1)^2 + Abs[x] - 3 x, x \[Distributed] NormalDistribution[0, 1]]], HoldForm[ Expectation[ x^10 + 11, {x, y} \[Distributed] MultivariatePoissonDistribution[1, {2, 3}]]], HoldForm[ Expectation[ x + y^2 + UnitBox[z - 2/3], {x, y, z} \[Distributed] DirichletDistribution[{2, 3, 4, 7}]]], HoldForm[ Expectation[x^2 + x + 54, x \[Distributed] CensoredDistribution[{3, 11}, ExponentialDistribution[\[Lambda]]]]], HoldForm[ Expectation[x^5 + 3 x + 166, x \[Distributed] EmpiricalDistribution[{1, 2, 4 E, 5, 7 Pi, 9}]]], HoldForm[ Expectation[E^x + 2, x \[Distributed] ProbabilityDistribution[3/4 (x^2 + 2 x), {x, 0, 1}]]], HoldForm[ NExpectation[ x^2 + E^(E^(-y^2)) + 1, {x, y} \[Distributed] BinormalDistribution[1/2]]]};
In[2]:=
X
FormulaGallery[forms_List] := Module[{vals = ParallelMap[ReleaseHold, forms]}, Text@TraditionalForm@ Grid[Table[{forms[[i]], vals[[i]]}, {i, Length[forms]}], Dividers -> All, Spacings -> {1, 2}, Alignment -> {Center, Center}, BaseStyle -> {FontFamily -> "Verdana"}, Background -> {None, {{Hue[.6, .15, .9], GrayLevel[.9]}}}, FrameStyle -> Directive[Thick, White]]]
In[3]:=
X
Pane[FormulaGallery[expectations] , 550]
Out[3]=