我正在使用lmfit来拟合拉曼数据。我正在使用7个高斯峰和一个线性背景(这些峰中有5个已知,其中两个未知)我已经包含了一个权重数组(stdev的反平方)。当我包括权重时 - 视觉上的拟合看起来好得多,并且绘制的残差也具有较少的结构,然而,卡方和减小的卡方值被报告为0.我不确定我是否使用加权值正确,或者可能无法正确解释结果。我在下面复制了我的代码。 非常感谢你的帮助
[[Model]]
(((((((Model(gaussian, prefix='one_') + Model(gaussian, prefix='two_')) + Model(gaussian, prefix='three_')) + Model(gaussian, prefix='unknown_')) + Model(gaussian, prefix='unknown2_')) + Model(gaussian, prefix='six_')) + Model(gaussian, prefix='seven_')) + Model(linear, prefix='lin1_'))
[[Fit Statistics]]
# function evals = 366
# data points = 172
# variables = 23
chi-square = 0.000
reduced chi-square = 0.000
Akaike info crit = -2481.840
Bayesian info crit = -2409.448
[[Variables]]
lin1_intercept: 7.87347446 +/- 0.202758 (2.58%) (init= 16.00284)
lin1_slope: -0.00399367 +/- 0.000115 (2.88%) (init=-0.006952215)
one_sigma: 21.2666157 +/- 1.423474 (6.69%) (init= 2)
one_center: 1204.02129 +/- 1.132164 (0.09%) (init= 1200)
one_amplitude: 102.715569 +/- 9.153523 (8.91%) (init= 10)
one_fwhm: 50.0790521 +/- 3.352026 (6.69%) == '2.3548200*one_sigma'
one_height: 1.92685033 +/- 0.073258 (3.80%) == '0.3989423*one_amplitude/max(1.e-15, one_sigma)'
two_sigma: 25.7977895 +/- 0.871817 (3.38%) (init= 2)
two_center: 1287.20816 +/- 1.068676 (0.08%) (init= 1275)
two_amplitude: 527.208091 +/- 24.04663 (4.56%) (init= 10)
two_fwhm: 60.7491508 +/- 2.052973 (3.38%) == '2.3548200*two_sigma'
two_height: 8.15285388 +/- 0.212054 (2.60%) == '0.3989423*two_amplitude/max(1.e-15, two_sigma)'
three_sigma: 19.5097449 +/- 0.798387 (4.09%) (init= 2)
three_center: 1444.94305 +/- 0.757566 (0.05%) (init= 1450)
three_amplitude: 518.683054 +/- 24.82361 (4.79%) (init= 10)
three_fwhm: 45.9419376 +/- 1.880058 (4.09%) == '2.3548200*three_sigma'
three_height: 10.6062181 +/- 0.249698 (2.35%) == '0.3989423*three_amplitude/max(1.e-15, three_sigma)'
unknown_sigma: 33.8695907 +/- 4.913019 (14.51%) (init= 2)
unknown_center: 1365.89866 +/- 2.572737 (0.19%) (init= 1355)
unknown_amplitude: 224.557732 +/- 33.37427 (14.86%) (init= 10)
unknown_fwhm: 79.7567896 +/- 11.56927 (14.51%) == '2.3548200*unknown_sigma'
unknown_height: 2.64501508 +/- 0.077333 (2.92%) == '0.3989423*unknown_amplitude/max(1.e-15, unknown_sigma)'
unknown2_sigma: 16.8566531 +/- 1.909319 (11.33%) (init= 2)
unknown2_center: 1497.93496 +/- 1.297153 (0.09%) (init= 1510)
unknown2_amplitude: 189.598971 +/- 27.39291 (14.45%) (init= 10)
unknown2_fwhm: 39.6943839 +/- 4.496103 (11.33%) == '2.3548200*unknown2_sigma'
unknown2_height: 4.48719263 +/- 0.196189 (4.37%) == '0.3989423*unknown2_amplitude/max(1.e-15, unknown2_sigma)'
six_sigma: 22.0949199 +/- 2.010271 (9.10%) (init= 2)
six_center: 1552.18018 +/- 1.324973 (0.09%) (init= 1550)
six_amplitude: 333.936881 +/- 54.65493 (16.37%) (init= 10)
six_fwhm: 52.0295593 +/- 4.733827 (9.10%) == '2.3548200*six_sigma'
six_height: 6.02951031 +/- 0.537614 (8.92%) == '0.3989423*six_amplitude/max(1.e-15, six_sigma)'
seven_sigma: 41.8944271 +/- 1.648292 (3.93%) (init= 2)
seven_center: 1603.04249 +/- 4.014783 (0.25%) (init= 1600)
seven_amplitude: 547.973799 +/- 48.61137 (8.87%) (init= 10)
seven_fwhm: 98.6538348 +/- 3.881433 (3.93%) == '2.3548200*seven_sigma'
seven_height: 5.21811474 +/- 0.274354 (5.26%) == '0.3989423*seven_amplitude/max(1.e-15, seven_sigma)'
[[Correlations]] (unreported correlations are < 0.100)
C(lin1_intercept, lin1_slope) = -0.999
C(seven_center, seven_amplitude) = -0.987
C(unknown_sigma, unknown_amplitude) = 0.980
C(unknown2_sigma, unknown2_amplitude) = 0.971
C(seven_sigma, seven_center) = -0.966
C(seven_sigma, seven_amplitude) = 0.953
C(six_amplitude, seven_amplitude) = -0.946
C(six_amplitude, seven_center) = 0.935
C(one_sigma, one_amplitude) = 0.920
C(six_sigma, six_amplitude) = 0.910
C(two_amplitude, unknown_sigma) = -0.900
C(two_amplitude, unknown_amplitude) = -0.896
C(two_center, unknown_amplitude) = -0.886
C(two_center, unknown_sigma) = -0.880
C(six_amplitude, seven_sigma) = -0.877
C(three_sigma, three_amplitude) = 0.871
C(two_center, two_amplitude) = 0.858
C(lin1_intercept, one_amplitude) = -0.844
C(lin1_slope, one_amplitude) = 0.839
C(two_sigma, two_amplitude) = 0.826
C(two_sigma, unknown_center) = 0.820
C(two_sigma, unknown_amplitude) = -0.813
C(two_amplitude, unknown_center) = 0.805
C(two_center, unknown_center) = 0.799
C(six_sigma, seven_amplitude) = -0.784
C(two_sigma, unknown_sigma) = -0.764
C(lin1_intercept, one_sigma) = -0.758
C(six_sigma, seven_center) = 0.754
C(lin1_slope, one_sigma) = 0.754
C(three_amplitude, unknown2_amplitude) = -0.748
C(two_sigma, two_center) = 0.737
C(unknown_center, unknown_amplitude) = -0.731
C(three_amplitude, unknown2_sigma) = -0.717
C(three_center, unknown2_amplitude) = -0.713
C(three_center, unknown2_sigma) = -0.705
C(three_sigma, unknown2_amplitude) = -0.696
C(unknown_sigma, unknown_center) = -0.688
C(unknown2_amplitude, six_sigma) = -0.682
C(unknown2_amplitude, six_center) = 0.681
C(unknown2_sigma, six_center) = 0.675
C(six_sigma, seven_sigma) = -0.671
C(three_sigma, unknown_sigma) = -0.662
C(three_amplitude, unknown_sigma) = -0.660
C(unknown2_sigma, six_sigma) = -0.653
C(three_sigma, unknown2_sigma) = -0.643
C(three_sigma, unknown_amplitude) = -0.640
C(three_amplitude, unknown_amplitude) = -0.631
C(three_center, three_amplitude) = 0.621
C(one_center, two_sigma) = -0.620
C(three_sigma, three_center) = 0.548
C(two_amplitude, three_amplitude) = 0.542
C(unknown2_sigma, six_amplitude) = -0.539
C(unknown2_amplitude, six_amplitude) = -0.533
C(two_amplitude, three_sigma) = 0.518
C(two_center, three_amplitude) = 0.517
C(one_amplitude, two_sigma) = -0.497
C(two_center, three_sigma) = 0.494
C(one_sigma, two_sigma) = -0.484
C(unknown2_center, six_sigma) = -0.483
C(one_center, two_amplitude) = -0.468
C(one_amplitude, unknown_amplitude) = 0.442
C(one_sigma, one_center) = 0.431
C(one_center, one_amplitude) = 0.422
C(three_sigma, unknown2_center) = 0.416
C(one_center, unknown_center) = -0.414
C(one_sigma, unknown_amplitude) = 0.408
C(two_sigma, three_amplitude) = 0.406
C(three_center, six_center) = -0.404
C(three_amplitude, six_center) = -0.398
C(two_sigma, three_sigma) = 0.383
C(unknown2_center, six_amplitude) = -0.374
C(one_center, unknown_amplitude) = 0.364
C(three_amplitude, unknown2_center) = 0.358
C(three_center, six_sigma) = 0.356
C(one_amplitude, unknown_center) = -0.349
C(three_amplitude, six_sigma) = 0.348
C(three_sigma, six_center) = -0.340
C(one_center, unknown_sigma) = 0.337
C(unknown_sigma, unknown2_amplitude) = 0.333
C(unknown_amplitude, unknown2_amplitude) = 0.332
C(one_sigma, unknown_center) = -0.329
C(one_amplitude, unknown_sigma) = 0.324
C(unknown2_sigma, seven_amplitude) = 0.321
C(unknown2_amplitude, seven_amplitude) = 0.309
C(three_center, six_amplitude) = 0.301
C(one_sigma, unknown_sigma) = 0.300
C(unknown2_sigma, seven_center) = -0.297
C(three_amplitude, six_amplitude) = 0.296
C(three_sigma, six_sigma) = 0.294
C(unknown_sigma, unknown2_sigma) = 0.291
C(unknown_amplitude, unknown2_sigma) = 0.288
C(lin1_intercept, unknown_amplitude) = -0.286
C(lin1_slope, unknown_amplitude) = 0.284
C(unknown2_amplitude, seven_center) = -0.278
C(three_center, unknown2_center) = 0.277
C(one_sigma, two_amplitude) = -0.276
C(one_amplitude, two_amplitude) = -0.275
C(unknown2_center, seven_amplitude) = 0.272
C(unknown2_center, six_center) = 0.265
C(unknown2_center, seven_center) = -0.254
C(three_sigma, six_amplitude) = 0.252
C(unknown2_sigma, seven_sigma) = 0.249
C(two_amplitude, unknown2_amplitude) = -0.245
C(two_center, unknown2_amplitude) = -0.238
C(unknown_sigma, unknown2_center) = -0.237
C(three_amplitude, unknown_center) = 0.237
C(unknown_amplitude, unknown2_center) = -0.228
C(unknown2_amplitude, seven_sigma) = 0.225
C(six_sigma, six_center) = -0.220
C(two_amplitude, unknown2_sigma) = -0.215
C(six_center, seven_center) = 0.212
C(one_amplitude, seven_sigma) = 0.211
C(one_center, two_center) = -0.208
C(two_center, unknown2_sigma) = -0.207
C(unknown2_center, seven_sigma) = 0.207
C(lin1_intercept, seven_sigma) = -0.205
C(six_center, seven_sigma) = -0.205
C(six_center, seven_amplitude) = -0.205
C(one_amplitude, two_center) = -0.201
C(one_amplitude, seven_amplitude) = 0.190
C(lin1_intercept, two_sigma) = 0.189
C(one_sigma, seven_sigma) = 0.188
C(lin1_slope, two_sigma) = -0.188
C(two_sigma, unknown2_amplitude) = -0.187
C(lin1_slope, seven_sigma) = 0.186
C(lin1_intercept, seven_amplitude) = -0.185
C(two_amplitude, unknown2_center) = 0.183
C(two_center, unknown2_center) = 0.173
C(one_center, three_amplitude) = -0.173
C(one_sigma, seven_amplitude) = 0.170
C(three_center, seven_amplitude) = -0.170
C(lin1_slope, seven_amplitude) = 0.169
C(one_sigma, two_center) = -0.166
C(three_amplitude, seven_amplitude) = -0.166
C(lin1_intercept, unknown_sigma) = -0.164
C(lin1_slope, unknown_sigma) = 0.163
C(three_sigma, unknown_center) = 0.162
C(two_sigma, unknown2_sigma) = -0.161
C(three_center, seven_center) = 0.160
C(one_center, three_sigma) = -0.157
C(three_amplitude, seven_center) = 0.156
C(lin1_intercept, unknown_center) = 0.146
C(lin1_slope, unknown_center) = -0.146
C(one_amplitude, seven_center) = -0.145
C(three_sigma, seven_amplitude) = -0.145
C(unknown_amplitude, six_sigma) = -0.141
C(unknown_amplitude, six_amplitude) = -0.137
C(unknown_sigma, six_center) = 0.136
C(lin1_intercept, seven_center) = 0.135
C(three_center, unknown_center) = -0.135
C(three_sigma, seven_center) = 0.134
C(unknown_sigma, six_sigma) = -0.133
C(three_center, seven_sigma) = -0.132
C(two_sigma, unknown2_center) = 0.132
C(three_amplitude, seven_sigma) = -0.130
C(one_sigma, seven_center) = -0.130
C(unknown_amplitude, six_center) = 0.126
C(one_amplitude, three_sigma) = -0.123
C(one_amplitude, six_amplitude) = -0.122
C(unknown_sigma, six_amplitude) = -0.122
C(lin1_slope, seven_center) = -0.121
C(unknown_amplitude, seven_amplitude) = 0.118
C(three_sigma, seven_sigma) = -0.116
C(unknown_amplitude, seven_sigma) = 0.114
C(one_sigma, three_sigma) = -0.113
C(unknown2_center, unknown2_amplitude) = 0.111
C(one_sigma, six_amplitude) = -0.109
C(unknown2_sigma, unknown2_center) = 0.109
C(one_amplitude, unknown2_amplitude) = 0.107
C(two_amplitude, six_center) = -0.107
C(lin1_intercept, six_amplitude) = 0.105
C(lin1_intercept, two_center) = 0.101
输出包括权重:
{{1}}
答案 0 :(得分:2)
卡方统计的报告在您使用的版本中限制为3位数。我相信这是在最新版本(0.9.9)中修复的,并且在最新的开发版本中肯定是固定的。您也可以自己更精确地打印出值:
print("chi-square = %14.8g, reduced chi-square = %14.8g" % (out.chisqr, out.redchi))
但是:我认为使用“stdev的反平方”的权重可能不是你想要的。为清楚起见,权重是应用于(数据模型)的乘法因子,然后卡方将是“Sum [(数据模型)*权重] ** 2”。因此,我认为使用“权重= 1./(数据的stddev)”(即,不是平方)是预期正态分布的数据的最常用方法,并且您的拉曼数据可能至少在通过计算小数字来控制没有信号的感觉(优先选择Poission统计数据)。
希望有所帮助。