# cdf 函数

服从某个分布的变量取值至多为某个值的概率。

## 怎么写

### cdf(distribution, x)

**distribution**

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

**x**

该值。接受一个表达式。

## 示例

- $\displaystyle F_{X}(x),\ X \sim \mathcal{N}(0, 1) = \frac{\operatorname{erf}\left(\frac{\sqrt{2} x}{2}\right)+1}{2}$

  `cdf(normal_distribution(0, 1), x)`

  在求解器中，`cdf(normal_distribution(0, 1), x)` 的结果是 `(erf(sqrt(2)*x/2) + 1)/2`。

  [在求解器中打开](https://zh.hilberon.com/?q=cdf%28normal_distribution%280%2C%201%29%2C%20x%29)
- $\displaystyle F_{X}(2),\ X \sim \mathrm{B}\left(5, \frac{1}{3}\right) = \frac{64}{81}$

  `cdf(binomial_distribution(5, 1/3), 2)`

  在求解器中，`cdf(binomial_distribution(5, 1/3), 2)` 的结果是 `64/81`。

  [在求解器中打开](https://zh.hilberon.com/?q=cdf%28binomial_distribution%285%2C%201%2F3%29%2C%202%29)

## 示例中用到的函数

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

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

  n 次独立试验中成功的次数，每次试验成功的概率为 p。

## 相关函数

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

  两个等长列表的相关系数。
- [covariance](https://zh.hilberon.com/library/covariance)

  两个等长列表的样本协方差。
- [affine_sde_moments](https://zh.hilberon.com/library/affine_sde_moments)

  从 x0 出发的 dX = (a + b X) dt + sigma dW 在时刻 t 的均值和方差。
- [cvar](https://zh.hilberon.com/library/cvar)

  损失的条件风险价值：其在最差的占比 1 - level 上的期望值。
- [wiener_process](https://zh.hilberon.com/library/wiener_process)

  带漂移 mu 和噪声 sigma、从 0 开始的布朗运动。
- [distributed](https://zh.hilberon.com/library/distributed)

  变量及其所服从的分布，供概率和期望读取。

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