类型错误:ndarray不是可赎回scipy.stats.kstest()

2024-05-13 02:22:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试进行Kolmogorov-Smirnov测试来比较经验分布和F分布(我知道这些不能直接比较,但是我将使用引导)。我对scipy KS测试有问题:

readLengths = [list,of,int,values,...]
x = stats.f.fit(readLengths)
dfn=x[0]
dfd=x[1]
stats.kstest(readLengths,stats.f.rvs(dfn,dfd,size=100))

我得到了错误

^{pr2}$

它指向stats.kstest行。我假设这是readLength数组的问题,但是文档说它可以使用1D数组,所以不确定我为什么会有这个问题。另外,有趣的是,在这个函数中,可以用“norm”命名正态分布,但“f”似乎无效,尽管它是f分布的scipy名称。在


Tags: ofstatsscipy数组经验listintvalues
1条回答
网友
1楼 · 发布于 2024-05-13 02:22:43

来自the docs

cdf : str or callable

If a string, it should be the name of a distribution in scipy.stats. If rvs is a string then cdf can be False or the same as rvs. If a callable, that callable is used to calculate the cdf.

kstest的第二个参数应该是一个字符串或者一个接受分位数作为输入并返回CDF的可调用对象。相反,你是在传球

stats.f.rvs(dfn,dfd,size=100)

其计算结果为np.ndarray


一种选择是使用所需的参数构造一个冻结的PDF,然后将其.cdf方法作为第二个参数传递给kstest

^{pr2}$

相关问题 更多 >