(博客主亲自录制视频教程,QQ:231469242)
累积分布函数(cumulative distribution function)定义:对连续函数,所有小于等于a的值,其出现概率的和。F(a)=P(x<=a)
python statsmodels包支持计算和绘制累积分布函数
import numpy as npimport statsmodels.api as sm # recommended import according to the docsimport matplotlib.pyplot as pltsample = np.random.uniform(0, 1, 50)ecdf = sm.distributions.ECDF(sample)#等差数列,用于绘制X轴数据x = np.linspace(min(sample), max(sample))# x轴数据上值对应的累计密度概率y = ecdf(x)#绘制阶梯图plt.step(x, y)plt.show()