Expectation

Expectation[expr,xdist]
gives the expectation of expr under the assumption that x follows the probability distribution dist.

Expectation[expr,xdata]
gives the expectation of expr under the assumption that x follows the probability distribution given by data.

Expectation[expr,{x1,x2,}dist]
gives the expectation of expr under the assumption that {x1,x2,} follows the multivariate distribution dist.

Expectation[expr,{x1dist1,x2dist2,}]
gives the expectation of expr under the assumption that x1, x2, are independent and follow the distributions dist1, dist2, .

Expectation[exprpred,]
gives the conditional expectation of expr given pred.

Details and OptionsDetails and Options

  • Expectation is also known as expected value.
  • xdist can be entered as x EscdistEsc dist or x[Distributed]dist.
  • exprpred can be entered as expr EsccondEsc pred or expr[Conditioned]pred.
  • For a continuous distribution dist, the expectation of expr is given by where is the probability density function of dist and the integral is taken over the domain of dist.
  • For a discrete distribution dist, the probability of expr is given by where is the probability density function of dist and the summation is taken over the domain of dist.
  • For a dataset data, the expectation of expr is given by Sum[expr,{x,data}]/Length[data].
  • Univariate data is given as a list of values {v1,v2,} and multivariate data is given as a list of vectors {{v11,,v1m},{v21,,v2m},}.
  • Expectation[expr,{x1dist1,x2dist2}] corresponds to Expectation[Expectation[expr,x2dist2],x1dist1] so that the last variable is summed or integrated first.
  • N[Expectation[]] calls NExpectation for expectations that cannot be done symbolically.
  • The following options can be given:
  • Assumptions$Assumptionsassumptions to make about parameters
    GenerateConditionsFalsewhether to generate conditions on parameters
    MethodAutomaticwhat method to use
    TargetUnitsAutomaticunits to display in the output

Background & Context
Background & Context

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Compute the expectation of a polynomial expression:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=

Compute the expectation of an arbitrary expression:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Compute a conditional expectation:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2010
(8.0)
| Updated in 2016
(10.4)
Translate this page: