导入依赖的库
!pip install pandas==0.25.0
!pip install matplotlib==3.1.0
!pip install seaborn==0.9.0
!pip install numpy==1.18.0
!pip install scipy==1.1.0
import pandas as pd
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy import stats
from scipy.stats import norm
%matplotlib inline
定义一个正态分布和直方图的帮助函数
def NormalandHistogram( DataFrame):
mu=DataFrame.mean()
sigma=DataFrame.std()
x=DataFrame.values.flatten()
# the histogram of the data
n, bins, patches = plt.hist(x, 10, density=1, facecolor='green', alpha=0.75)
# add a 'best fit' line
y = norm.pdf( bins, mu, sigma)
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.xlabel('x')
plt.ylabel('Probability')
</