【发布时间】:2018-09-26 19:12:30
【问题描述】:
我需要绘制从文件中读取的整数值的 cdf。我正在关注示例here。我不确定如何规范化 pdf 的数据,然后计算 cdf。
import numpy as np
from pylab import *
with open ("D:/input_file.txt", "r+") as f:
data = f.readlines()
X = [int(line.strip()) for line in data]
Y = exp([-x**2 for x in X]) # is this correct?
# Normalize the data to a proper PDF
Y /= ... # not sure what to write here
# Compute the CDF
CY = ... # not sure what to write here
# Plot both
plot(X,Y)
plot(X,CY,'r--')
show()
【问题讨论】:
-
你能分享你的输入数据吗?
-
88 93 184 91 107 170 88 107 167 90
-
CDF是累积分布函数吗?
-
是的,还有总和为 1 的 pdf。
标签: python matplotlib cdf