文章目录
一、初步
对于大量样本来说,如果想快速获知其分布特征,最方便的可视化方案就是直方图,即统计落入不同区间中的样本个数。
以正态分布为例
import numpy as np
import matplotlib.pyplot as plt
xs = np.random.normal(0, 1, size=(5000))
fig = plt.figure()
for i,b in enumerate([10, 50, 100, 200],1):
ax = fig.add_subplot(2,2,i)
plt.hist(xs, bins=b)
plt.show()
其中bins参数用于调控区间个数,出图结果如下
二、参数
直方图函数的定义如下
hist(x, bins=None, range=None, density=False, weights=None, cumulative