从另一个线程(@ EnricoGiampieri对累积分布图python 的回答)中提示,我写道:
# plot cumulative density function of nearest nbr distances
# evaluate the histogram
values, base = np.histogram(nearest, bins=20, density=1)
#evaluate the cumulative
cumulative = np.cumsum(values)
# plot the cumulative function
plt.plot(base[:-1], cumulative, label='data')
Run Code Online (Sandbox Code Playgroud)
我从np.histogram上的文档中输入了密度= 1,其中说:
"请注意,除非选择单位宽度的区间,否则直方图值的总和不会等于1;它不是概率质量函数."
确实,在绘制时,它们并不总和为1.但是,我不理解"统一宽度的箱子".当我将箱子设置为1时,当然,我得到一个空图表; 当我将它们设置为种群大小时,我得不到1(更像是0.2).当我使用建议的40个箱子时,它们的总和大约为.006.
有人可以给我一些指导吗?谢谢!