1
def stat_function(x):
center = x[len(x)/2]
ecdf = ECDF(xx)
percentile = (1 - ecdf(center)) * 100
print percentile
return percentile
主:
print generic_filter(table,
function=stat_function,
size=window_size,
mode=mode,
extra_arguments=(-1,))
我得到的输出:
[[84 76 76 76 76 76 76 76 76 60]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[52 48 48 48 48 48 48 48 48 39]
[24 15 15 15 15 15 15 15 15 0]]
一切都很好,但如果我打印的“百分'在我的函数返回之前,我看到我所有的15s实际上是16.0s,而我的39s是40.0s。函数generic_filter需要re转动一个浮点数并返回“16.0”,但在构建的数组中,它被转换为一个int并变成“15”。事实上 print percentile, int(percentile)
将显示 “16.0,15”。
如果有人可以帮助我了解为什么这个SciPy的的功能需要一个浮动,然后扔在一个int,为什么INT(16.0)给出了15,我在这里。
PS:即使numpy.array(generif_filter(...), dtype=numpy.float)
,我得到的整数的错误的表。