2017-04-15 41 views
0

下面的python代码没有显示chi2和简化chi2。它只显示变量和相关性。为什么是这样?我在python stats打印输出中看不到任何chi2

代码如下所示。

#!/usr/bin/env python 
#<examples/doc_model1.py> 
from numpy import sqrt, pi, exp, linspace, loadtxt 
from lmfit import Model 

import matplotlib.pyplot as plt 

data = loadtxt('model1d_gauss.dat') 
x = data[:, 0] 
y = data[:, 1] 

def gaussian(x, amp, cen, wid): 
    "1-d gaussian: gaussian(x, amp, cen, wid)" 
    return (amp/(sqrt(2*pi)*wid)) * exp(-(x-cen)**2 /(2*wid**2)) 

gmodel = Model(gaussian) 
result = gmodel.fit(y, x=x, amp=5, cen=5, wid=1) 

print(result.fit_report()) 

plt.plot(x, y,   'bo') 
plt.plot(x, result.init_fit, 'k--') 
plt.plot(x, result.best_fit, 'r-') 
plt.show() 
#<end examples/doc_model1.py> 

的输出低于

[[Model]] 
    Model(gaussian) 
[[Variables]] 
    amp: 8.88021829 +/- 0.113594 (1.28%) (init= 5) 
    cen: 5.65866102 +/- 0.010304 (0.18%) (init= 5) 
    wid: 0.69765468 +/- 0.010304 (1.48%) (init= 1) 
[[Correlations]] (unreported correlations are < 0.100) 
    C(amp, wid)     = 0.577 

回答