from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(1, 1)
# loc:均值 scale:标准差
loc=1
scale=2
# 均值, 方差, 偏度, 峰度
mean, var, skew, kurt = norm.stats(loc,scale,moments='mvsk')
# ppf:累积分布函数的反函数。q=0.01时,ppf就是p(X<x)=0.01时对应的x值。
x = np.linspace(norm.ppf(0.01,loc,scale),
norm.ppf(0.99,loc,scale), 100)
ax.plot(x, norm.pdf(x,loc,scale),
'r-', lw=5, alpha=0.6, label='norm pdf')
特殊情形:
fig, ax = plt.subplots(1, 1)
mean, var, skew, kurt = norm.stats(moments='mvsk')
x = np.linspace(norm.ppf(0.01),
norm.ppf(0.99), 100)
ax.plot(x, norm.pdf(x),
'r-', lw=5, alpha=0.6, label='norm pdf')