# Mean (mean)

The average of a list of numbers, or the expected value of a distribution.

## How to write it

### mean(data)

The sum of the data divided by how many there are.

**data**

The numbers to average. Symbols are allowed. Takes a list.

### mean(distribution)

The expected value of a distribution.

**distribution**

A distribution such as normal_distribution(mu, sigma). Takes an expression.

### mean(process)

The expected value of a stochastic process at a time.

**process**

A process at a time, written construct(p, t), or p(t) for a stored process p. Takes an expression.

### mean(process, t)

The same, with the time written beside the process.

**process**

A process such as geometric_brownian_motion_process(mu, sigma, x0). Takes an expression.

**t**

The time, a variable or a number. Takes an expression.

## Examples

- $\displaystyle 2, 4, 4, 4, 5, 5, 7, 9 = 5$

  `mean([2, 4, 4, 4, 5, 5, 7, 9])`

  In the solver, `mean([2, 4, 4, 4, 5, 5, 7, 9])` gives `5`.

  [Open in the solver](https://hilberon.com/?q=mean%28%5B2%2C%204%2C%204%2C%204%2C%205%2C%205%2C%207%2C%209%5D%29)
- $\displaystyle a, b, c = \frac{a+b+c}{3}$

  `mean([a, b, c])`

  In the solver, `mean([a, b, c])` gives `(a + b + c)/3`.

  [Open in the solver](https://hilberon.com/?q=mean%28%5Ba%2C%20b%2C%20c%5D%29)
- $\displaystyle E[X],\ X \sim \mathcal{N}(\mu, \sigma) = \mu$

  `mean(normal_distribution(mu, sigma))`

  In the solver, `mean(normal_distribution(mu, sigma))` gives `mu`.

  [Open in the solver](https://hilberon.com/?q=mean%28normal_distribution%28mu%2C%20sigma%29%29)
- $\displaystyle E[X],\ X \sim \mathrm{B}\left(10, \frac{1}{4}\right) = \frac{5}{2}$

  `mean(binomial_distribution(10, 1/4))`

  In the solver, `mean(binomial_distribution(10, 1/4))` gives `5/2`.

  [Open in the solver](https://hilberon.com/?q=mean%28binomial_distribution%2810%2C%201%2F4%29%29)
- $\displaystyle \operatorname{construct}(\operatorname{GBM}(\mu, \sigma, x_{0}), t) = x_{0} e^{\mu t}$

  `mean(construct(geometric_brownian_motion_process(mu, sigma, x0), t))`

  In the solver, `mean(construct(geometric_brownian_motion_process(mu, sigma, x0), t))` gives `x0*e^(mu*t)`.

  [Open in the solver](https://hilberon.com/?q=mean%28construct%28geometric_brownian_motion_process%28mu%2C%20sigma%2C%20x0%29%2C%20t%29%29)
- $\displaystyle E[X_{t}],\ X \sim \operatorname{GBM}(\mu, \sigma, x_{0}) = x_{0} e^{\mu t}$

  `mean(geometric_brownian_motion_process(mu, sigma, x0), t)`

  In the solver, `mean(geometric_brownian_motion_process(mu, sigma, x0), t)` gives `x0*e^(mu*t)`.

  [Open in the solver](https://hilberon.com/?q=mean%28geometric_brownian_motion_process%28mu%2C%20sigma%2C%20x0%29%2C%20t%29)
- $\displaystyle E[X_{t}],\ X \sim \operatorname{OU}(\mu, \sigma, \theta, x_{0}) = \frac{x_{0}-\mu}{e^{t \theta}}+\mu$

  `mean(ornstein_uhlenbeck_process(mu, sigma, theta, x0), t)`

  In the solver, `mean(ornstein_uhlenbeck_process(mu, sigma, theta, x0), t)` gives `e^(-t*theta)*(x0 - mu) + mu`.

  [Open in the solver](https://hilberon.com/?q=mean%28ornstein_uhlenbeck_process%28mu%2C%20sigma%2C%20theta%2C%20x0%29%2C%20t%29)

## Functions its examples use

- [normal_distribution](https://hilberon.com/library/normal_distribution)

  The normal distribution with mean mu and standard deviation sigma.
- [binomial_distribution](https://hilberon.com/library/binomial_distribution)

  The number of successes in n independent trials that each succeed with chance p.
- [construct](https://hilberon.com/library/construct)

  Apply a head that is itself computed to arguments, as in f'(0) or (x => body)(a).
- [geometric_brownian_motion_process](https://hilberon.com/library/geometric_brownian_motion_process)

  A process that grows at rate mu with relative noise sigma, started at x0.
- [ornstein_uhlenbeck_process](https://hilberon.com/library/ornstein_uhlenbeck_process)

  A process pulled toward mu at rate theta, with noise sigma, started at x0.

## Related functions

- [median](https://hilberon.com/library/median)

  The middle value of a list of numbers, or the mean of the two middle ones.
- [ito_process](https://hilberon.com/library/ito_process)

  A process given by its drift and diffusion: dX = drift dt + diffusion dW.
- [mode](https://hilberon.com/library/mode)

  The most frequent value of a list, or a list of them when several are equally frequent.
- [ito_integral](https://hilberon.com/library/ito_integral)

  The Itô integral of an expression of the Wiener value w and the time s, from 0 to t.
- [ito_formula_data](https://hilberon.com/library/ito_formula_data)

  The certified record behind ito_formula: its result, validity, certificate and theorem.
- [ito_formula](https://hilberon.com/library/ito_formula)

  Itô's lemma: the differential of an expression of states that follow an Itô process.

---
Source: https://hilberon.com/library/mean
