您要求的是预期直方图的图表 .
假设[a,b]是直方图的x个区间之一 . 对于大小为n的随机样本,间隔中的预期样本数为
(cdf(b) - cdf(a))*n
其中cdf(x)是累积分布函数 . 要绘制预期的直方图,您将计算每个bin的值 .
下面的脚本显示了在matplotlib直方图上绘制预期直方图的一种方法 . 它生成这个图:
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
# Generate log-normal distributed set of samples
np.random.seed(1234)
samples = np.random.lognormal(mean=1., sigma=.4, size=10000)
# Make a fit to the samples.
shape, loc, scale = scipy.stats.lognorm.fit(samples, floc=0)
# Create the histogram plot using matplotlib. The first two values in
# the tuple returned by hist are the number of samples in each bin and
# the values of the histogram's bin edges. counts has length num_bins,
# and edges has length num_bins + 1.
<