有没有办法在python中计算CCDF?

时间:2013-12-17 08:18:19

标签: python graph

我已经用Python编写了一个代码来制作CDF图。 无论如何,我真正想要的是CCDF图。 我只知道CCDF = 1 - CDF,但我不知道如何在python中应用它。

有没有人知道在Python中计算CCDF的方法?

1 个答案:

答案 0 :(得分:0)

在这里,我放置了一个代码,用于使用x =您的原始值数组在python中绘制ccdf图

colors = list(mcolors.CSS4_COLORS.keys())
fig, ax = plt.subplots(figsize=(15,7))
bins = 100
cnt_color = 11
legends = []



#cdf = your_data.cumsum(0)
#ccdf = 1 - cdf
ccdf =  your_data
ax.hist(ccdf, bins=bins, density=True, histtype='step', color=colors[cnt_color], linewidth=3,cumulative=-1, label='Empirical')
legends.append('whatever')


ax.set_title('CCDF total de registros', color = mycolor)
ax.set_xlabel('#número de vendas', color = mycolor)
plt.xlim(0,50)
plt.xticks(range(0,50,5),color = mycolor)

ax.grid(True)
ax.set_ylabel('porcentagem (prob. de ocorrência)', color = mycolor)
plt.yticks(np.arange(0,1.0,0.1), color = mycolor, fontsize=24)
plt.legend(legends)
plt.savefig('graphs_results.png')