scipy.stats.norm
可以方便地访问正态分布的pdf
为了使其与采样数据正确对应,直方图应该
显示密度而不是计数,所以使用
norm_hist=True
seaborn.distplot
打电话。
import numpy as np
import seaborn as sns
from scipy import stats
import matplotlib.pyplot as plt
x = np.random.standard_normal(1000)
ax = sns.distplot(x, kde = False, norm_hist=True)
# calculate the pdf over a range of values
xx = np.arange(-4, +4, 0.001)
yy = stats.norm.pdf(xx)
# and plot on the same axes that seaborn put the histogram
ax.plot(xx, yy, 'r', lw=2)