我需要对列表中的值进行归一化以产生(累积)概率分布,但目前我只是得到 0。
这就是我正在做的事情:
tests = []
#some code to populate tests which simulates
count = [x[0] for x in tests]
found = [x[1] for x in tests]
found.sort()
num = Counter(found)
freqs = [x for x in num.values()]
cumsum = [sum(item for item in freqs[0:rank+1]) for rank in xrange(len(freqs))]
normcumsum = [float(x/numtests) for x in cumsum]
目前 cumsum 和 normcumsum 是:
cumsum = [1, 2, 6, 12, 28, 39, 64, 85, 96, 98, 99, 100]
normcumsum = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]
如何让 normcumsum 包含 cumsum/100?
N>B 是的,这些变量名有点笨。