# 均值（Mean，mean）

一组数的平均值，或分布的期望值。

## 怎么写

### mean(data)

数据之和除以数据个数。

**data**

要求平均值的数。允许使用符号。接受一个列表。

### mean(distribution)

分布的期望值。

**distribution**

一个分布，例如 normal_distribution(mu, sigma)。接受一个表达式。

### mean(process)

随机过程在某一时刻的期望值。

**process**

某一时刻的过程，写作 construct(p, t)，或对已存储的过程 p 写作 p(t)。接受一个表达式。

### mean(process, t)

同上，时间写在过程旁边。

**process**

一个过程，例如 geometric_brownian_motion_process(mu, sigma, x0)。接受一个表达式。

**t**

时间，一个变量或一个数。接受一个表达式。

## 示例

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

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

  在求解器中，`mean([2, 4, 4, 4, 5, 5, 7, 9])` 的结果是 `5`。

  [在求解器中打开](https://zh.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])`

  在求解器中，`mean([a, b, c])` 的结果是 `(a + b + c)/3`。

  [在求解器中打开](https://zh.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))`

  在求解器中，`mean(normal_distribution(mu, sigma))` 的结果是 `mu`。

  [在求解器中打开](https://zh.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))`

  在求解器中，`mean(binomial_distribution(10, 1/4))` 的结果是 `5/2`。

  [在求解器中打开](https://zh.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))`

  在求解器中，`mean(construct(geometric_brownian_motion_process(mu, sigma, x0), t))` 的结果是 `x0*e^(mu*t)`。

  [在求解器中打开](https://zh.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)`

  在求解器中，`mean(geometric_brownian_motion_process(mu, sigma, x0), t)` 的结果是 `x0*e^(mu*t)`。

  [在求解器中打开](https://zh.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)`

  在求解器中，`mean(ornstein_uhlenbeck_process(mu, sigma, theta, x0), t)` 的结果是 `e^(-t*theta)*(x0 - mu) + mu`。

  [在求解器中打开](https://zh.hilberon.com/?q=mean%28ornstein_uhlenbeck_process%28mu%2C%20sigma%2C%20theta%2C%20x0%29%2C%20t%29)

## 示例中用到的函数

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

  均值为 mu、标准差为 sigma 的正态分布。
- [binomial_distribution](https://zh.hilberon.com/library/binomial_distribution)

  n 次独立试验中成功的次数，每次试验成功的概率为 p。
- [construct](https://zh.hilberon.com/library/construct)

  把本身是计算得到的头部作用于参数，例如 f'(0) 或 (x => body)(a)。
- [geometric_brownian_motion_process](https://zh.hilberon.com/library/geometric_brownian_motion_process)

  以速率 mu 增长、相对噪声为 sigma、从 x0 出发的过程。
- [ornstein_uhlenbeck_process](https://zh.hilberon.com/library/ornstein_uhlenbeck_process)

  以速率 theta 被拉向 mu、噪声为 sigma、从 x0 开始的随机过程。

## 相关函数

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

  一组数的中间值，或两个中间值的平均数。
- [ito_process](https://zh.hilberon.com/library/ito_process)

  由漂移项和扩散项给出的过程：dX = drift dt + diffusion dW。
- [mode](https://zh.hilberon.com/library/mode)

  列表中出现的频率最高的值；若有多个值频率相同，则返回由它们组成的列表。
- [ito_integral](https://zh.hilberon.com/library/ito_integral)

  由维纳值 w 和时间 s 构成的表达式在 0 到 t 上的 Itô 积分。
- [ito_formula_data](https://zh.hilberon.com/library/ito_formula_data)

  ito_formula 背后的认证记录：结果、有效性、证书与定理。
- [ito_formula](https://zh.hilberon.com/library/ito_formula)

  Itô 引理：对服从 Itô 过程的状态所构成表达式的微分。

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