小编Sea*_*ney的帖子

Python中的似然比检验

我在Python 2.7中计算似然比测试时遇到了麻烦.

我有两个模型和相应的似然值.我相信比较模型L2是否优于模型L1(如果模型密切相关)的规则是查看-2*log(L2/L1).

然后我想找到对应于-2*log(L2/L1)的p值,并将其与L2的重要性相关联,优先于L1.这是我到目前为止:

import numpy as np
from scipy.stats import chisqprob

L1 = 467400. # log(likelihood) of my 1st fit
L2 = 467414. # log(likelihood) of my 2nd fit

LR = -2. * np.log(L2 / L1) # LR = -5.9905e-05

p = chisqprob(LR, 1) # L2 has 1 DoF more than L1

print 'p: %.30f' % p # p = 1.000000000000000000000000000000

five_sigma = 1 - scipy.special.erf(5 / np.sqrt(2.))                  :-)
print '5 sigma: %.30f' % five_sigma

five_sigma_check = 1 - …
Run Code Online (Sandbox Code Playgroud)

python statistics scipy python-2.7

11
推荐指数
1
解决办法
7304
查看次数

标签 统计

python ×1

python-2.7 ×1

scipy ×1

statistics ×1