Expected Value

## Description

The Expected Value of a probability density function is

(1)\begin{align} E(X) = \int_{-\infty}^{\infty} x f(x) dx. \end{align}

The Sage cell below calculates the expected value of the exponential distribution when $\lambda=4$.

## Sage Cell

#### Code

```
l=4
f(X)=l*exp(-l*x)
E(X)=integral(x*f(X),x,0,+infinity)
E(X)
```

## Options

#### Expected Value for Discrete Distributions

The Expected Value of a discrete probability distribution function is

(2)\begin{align} E(X) = \sum_{x=0}^{\infty} x f(x) dx. \end{align}

The Sage cell below calculates the expected value of the poisson distribution when $\lambda=15$.

#### Code

```
lamb = 15
var('k')
f(k)=exp( -lamb) * (( lamb^k ) / ( factorial(k)))
sum(k * f(k) , k, 0, infinity)
```

## Tags

Primary Tags: Probability

Secondary Tags: Random Variables: Expectation, Continuous Distributions, Discrete Distributions

## Related Cells

None

## Attribute

Permalink:

Author:

Date: 16 Oct 2018 17:15

Submitted by: James A Phillips