Gauss error function

0. error function

erf(x)=1πxxet2dt

python 下的 math 标准库定义着 erf 的实现。

1. 从 error function 到标准正态分布 cdf 的实现

标准正态分布的累积分布函数无法用基本的解析形式表示,但却可通过的简单形式变换而计算得到:

Φ(x)=12+12erf(x/2)=12erfc(x/2)

2. python 实现

def phi(x, mu=0, sigma=1):
    return (1 + math.erf((x-mu) / math.sqrt(2) / math.sqrt(sigma)))/2
原文地址:https://www.cnblogs.com/mtcnn/p/9420970.html