我在scipy(scipy.stats.kstest)中使用Kolmogorov-Smirnov測試時遇到了麻煩。在線文檔(http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kstest.html)表示它需要樣本,cdf與只命名其中一個scipy的選項進行比較.stats分佈的CDF參數(和任選的幾個值)scipy.stats.kstest與非標準分發
只要所選擇的CDF不需要任何額外的參數,所有出現細
teststat,pval=stats.kstest(sample,'norm')
(其中樣品是值的列表)。 但是,對於其他需要額外修正的發行版,如t,chisquared等,它不適用於我。它正確地抗議,如果沒有進一步給出參數
teststat,pval=stats.kstest(sample,'t')
TypeError: _cdf() takes exactly 3 arguments (2 given)
如果給定參數,
teststat,pval=stats.kstest(sample,'t',24)
它抱怨
TypeError: cdf() argument after * must be a sequence, not int
現在我不能完全肯定這意味着什麼,但它似乎它不想int,24,而是一個int,(24)的序列。但是:
teststat,pval=stats.kstest(sample,'t',24)
TypeError: cdf() argument after * must be a sequence, not int
手動定義分佈不產生更好的結果要麼是因爲它不覺得這是調用的:
numargs = stats.t.numargs
[ df ] = [0.9,] * numargs
rv = stats.t(df)
teststat,pval=stats.kstest(sample,stats.t.cdf(numpy.linspace(0, numpy.minimum(rv.dist.b, 3)),df))
TypeError: 'numpy.ndarray' object is not callable
我該怎麼辦,使其工作? (谷歌搜索無論是kstest功能或各種錯誤消息,不要把任何東西來回答這個問題非常有用。)
感謝
感謝DSM, 你,當然,正確的。 (x,)是聲明序列的正確方法;我不熟悉那種變量類型。謝謝。 – 0range