---
title: "ExpectedValue"
language: "en"
type: "Symbol"
summary: "As of Version 8.0, ExpectedValue has been superseded by Expectation and NExpectation."
keywords: 
- expectation
- statistical expectation
canonical_url: "https://reference.wolfram.com/language/ref/ExpectedValue.html"
source: "Wolfram Language Documentation"
related_functions: 
  - 
    title: "CentralMoment"
    link: "https://reference.wolfram.com/language/ref/CentralMoment.en.md"
  - 
    title: "Mean"
    link: "https://reference.wolfram.com/language/ref/Mean.en.md"
  - 
    title: "Variance"
    link: "https://reference.wolfram.com/language/ref/Variance.en.md"
  - 
    title: "Skewness"
    link: "https://reference.wolfram.com/language/ref/Skewness.en.md"
  - 
    title: "Kurtosis"
    link: "https://reference.wolfram.com/language/ref/Kurtosis.en.md"
  - 
    title: "CharacteristicFunction"
    link: "https://reference.wolfram.com/language/ref/CharacteristicFunction.en.md"
  - 
    title: "Integrate"
    link: "https://reference.wolfram.com/language/ref/Integrate.en.md"
related_tutorials: 
  - 
    title: "Discrete Distributions"
    link: "https://reference.wolfram.com/language/tutorial/NumericalOperationsOnData.en.md#15659"
  - 
    title: "Continuous Distributions"
    link: "https://reference.wolfram.com/language/tutorial/NumericalOperationsOnData.en.md#11002"
---
# ExpectedValue

⚠ As of Version 8.0, ``ExpectedValue`` has been superseded by ``Expectation`` and ``NExpectation``.

ExpectedValue[f, list] gives the expected value of the pure function f with respect to the values in list.  

ExpectedValue[f, list, x] gives the expected value of the function f of x with respect to the values of list.

ExpectedValue[f, dist] gives the expected value of the pure function f with respect to the symbolic distribution dist.

ExpectedValue[f, dist, x] gives the expected value of the function f of x with respect to the symbolic distribution dist.

## Details and Options

* For the list $\left\{x_1,x_2,\ldots ,x_n\right\}$, the expected value of ``f`` is given by $\frac{1}{\text{\textit{$n$}}}\sum _{\text{\textit{$i$}}}$.

* For a continuous distribution ``dist``, the expected value of ``f`` is given by $\int \text{\textit{$f$}}(\text{\textit{$x$}}) \text{\textit{$p$}}(\text{\textit{$x$}})d\text{\textit{$x$}}$ where $\text{\textit{$p$}}(\text{\textit{$x$}})$ is the probability density function of ``dist`` and the integral is taken over the domain of ``dist``.

* For a discrete distribution ``dist``, the expected value of ``f`` is given by $\text{\textit{$\sum $}}\text{\textit{$f$}}(\text{\textit{$x$}}) \text{\textit{$p$}}(\text{\textit{$x$}})$ where $\text{\textit{$p$}}(\text{\textit{$x$}})$ is the probability mass function of ``dist`` and summation is over the domain of ``dist``.

* The following option can be given:

[`Assumptions`](https://reference.wolfram.com/language/ref/Assumptions.en.md) 	[`\$Assumptions`](https://reference.wolfram.com/language/ref/$Assumptions.en.md)	assumptions to make about parameters

---

## Examples (16)

### Basic Examples (3)

Find the expected value of $x^4$ in a Poisson distribution:

```wl
In[1]:= ExpectedValue[x ^ 4, PoissonDistribution[μ], x]

Out[1]= μ + 7 μ^2 + 6 μ^3 + μ^4
```

---

Use a pure function:

```wl
In[1]:= ExpectedValue[# ^ 4&, PoissonDistribution[μ]]

Out[1]= μ + 7 μ^2 + 6 μ^3 + μ^4
```

---

Expected value for a list:

```wl
In[1]:= ExpectedValue[Sin, {1, 4, 2, 5, 3, 7, 2}]

Out[1]= (1/7) (Sin[1] + 2 Sin[2] + Sin[3] + Sin[4] + Sin[5] + Sin[7])
```

### Scope (3)

Compute the expected value of any function:

```wl
In[1]:= ExpectedValue[x ^ 4 Exp[-Abs[x]], NormalDistribution[0, 1], x]

Out[1]= -2 (3 Sqrt[(2/π)] - 5 Sqrt[E] Erfc[(1/Sqrt[2])])
```

---

Do the computation numerically:

```wl
In[1]:= ExpectedValue[x ^ 4 Exp[-Abs[x]], NormalDistribution[0, 1.], x]

Out[1]= 0.444258
```

---

Obtain expectations with conditions:

```wl
In[1]:= ExpectedValue[x ^ n, CauchyDistribution[0, 1], x]

Out[1]= If[-1 < Re[n] < 1, (1/2) (1 + (-1)^n) Sec[(n π/2)], ExpectedValue[x^n, CauchyDistribution[0, 1], x, Assumptions -> !-1 < Re[n] < 1]]

In[2]:= ExpectedValue[x ^ n, CauchyDistribution[0, 1], x, Assumptions -> -1 < n < 1]

Out[2]= (1/2) (1 + (-1)^n) Sec[(n π/2)]
```

### Options (1)

#### Assumptions (1)

Obtain results correct for given assumptions on symbols:

```wl
In[1]:= ExpectedValue[x ^ n, ParetoDistribution[k, α], x]

Out[1]= k^α α If[α > Re[n], -(k^n - α/n - α), ExpectedValue[(k^-α x^n/α), ParetoDistribution[k, α], x, Assumptions -> α ≤ Re[n]]]

In[2]:= ExpectedValue[x ^ n, ParetoDistribution[k, α], x, Assumptions -> α > n]

Out[2]= -(k^n α/n - α)
```

### Applications (2)

Obtain the raw moments of a distribution:

```wl
In[1]:= ExpectedValue[x ^ n, ChiSquareDistribution[ν], x, Assumptions -> n > 0]

Out[1]= (2^n Gamma[n + (ν/2)]/Gamma[(ν/2)])
```

---

Construct a mixture density, here a Poisson‐inverse Gaussian mixture:

```wl
In[1]:= ExpectedValue[PDF[PoissonDistribution[μ], k], InverseGaussianDistribution[m, λ], μ, Assumptions -> k > 0]

Out[1]= (E^(λ/m) Sqrt[(2/π)] Sqrt[λ] ((λ/2 + (λ/m^2)))^(1/4) (-1 + 2 k) BesselK[-(1/2) + k, (Sqrt[λ (2 m^2 + λ)]/m)]/k!)
```

### Properties & Relations (7)

``ExpectedValue`` of a function is the integral or sum of that function times the ``PDF`` :

```wl
In[1]:= ExpectedValue[x ^ 3, ExponentialDistribution[λ], x]

Out[1]= (6/λ^3)

In[2]:= Integrate[x ^ 3 PDF[ExponentialDistribution[λ], x], {x, 0, Infinity}, Assumptions -> λ > 0]

Out[2]= (6/λ^3)

In[3]:= ExpectedValue[Exp[k], BinomialDistribution[n, p], k]

Out[3]= (1 + (-1 + E) p)^n

In[4]:= Sum[Exp[k] PDF[BinomialDistribution[n, p], k], {k, 0, n}]

Out[4]= (1 + (-1 + E) p)^n
```

---

``ExpectedValue`` of $e^{itx}$ for real ``t`` is the ``CharacteristicFunction`` :

```wl
In[1]:= ExpectedValue[Exp[I t x], GumbelDistribution[α, β], x, Assumptions -> Element[t, Reals]]

Out[1]= E^I t α Gamma[1 + I t β]

In[2]:= CharacteristicFunction[GumbelDistribution[α, β], t]

Out[2]= E^I t α Gamma[1 + I t β]
```

---

``ExpectedValue`` of a constant is the constant:

```wl
In[1]:= ExpectedValue[5, BetaDistribution[α, β], x]

Out[1]= 5
```

---

``ExpectedValue`` of a random variable is the ``Mean`` :

```wl
In[1]:= ExpectedValue[x, ChiSquareDistribution[ν], x]

Out[1]= ν

In[2]:= Mean[ChiSquareDistribution[ν]]

Out[2]= ν
```

---

``ExpectedValue`` of the squared difference from the ``Mean`` is the ``Variance`` :

```wl
In[1]:= ExpectedValue[(x - ν) ^ 2, ChiSquareDistribution[ν], x]

Out[1]= 2 ν

In[2]:= Variance[ChiSquareDistribution[ν]]

Out[2]= 2 ν
```

---

``ExpectedValue`` for a list is a ``Mean`` :

```wl
In[1]:= ExpectedValue[f, Range[5]]

Out[1]= (1/5) (f[1] + f[2] + f[3] + f[4] + f[5])

In[2]:= Mean[Map[f, Range[5]]]

Out[2]= (1/5) (f[1] + f[2] + f[3] + f[4] + f[5])
```

---

``CentralMoment`` is equivalent to an expected value:

```wl
In[1]:= list = Range[100];

In[2]:= ExpectedValue[(x - Mean[list]) ^ 5, list, x] == CentralMoment[list, 5]

Out[2]= True
```

## See Also

* [`CentralMoment`](https://reference.wolfram.com/language/ref/CentralMoment.en.md)
* [`Mean`](https://reference.wolfram.com/language/ref/Mean.en.md)
* [`Variance`](https://reference.wolfram.com/language/ref/Variance.en.md)
* [`Skewness`](https://reference.wolfram.com/language/ref/Skewness.en.md)
* [`Kurtosis`](https://reference.wolfram.com/language/ref/Kurtosis.en.md)
* [`CharacteristicFunction`](https://reference.wolfram.com/language/ref/CharacteristicFunction.en.md)
* [`Integrate`](https://reference.wolfram.com/language/ref/Integrate.en.md)

## Tech Notes

* [Discrete Distributions](https://reference.wolfram.com/language/tutorial/NumericalOperationsOnData.en.md#15659)
* [Continuous Distributions](https://reference.wolfram.com/language/tutorial/NumericalOperationsOnData.en.md#11002)

## History

* [Introduced in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) \| [Updated in 2008 (7.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn70.en.md)