我必须使用函数g(x)=(A*B*x)/(1+B*x))+K*x+L*x^n
拟合实验数据(x,y)。
这是我的代码:
x=[0;2;4;6;8;10;15;20;25;30;35;40;45;50;55;60;65;70;75;80;85;90];
y=[0.01;0.32;0.76;1.15;1.51;1.83;2.45;3.03;3.6;4.18;4.75;5.30;5.85;6.53;7.25;8.26;9.25;10.46;11.45;13.37;15.75;18.68];
g=fittype('((A*B*x)/(1+B*x))+K*x+L*x^n', 'independent',{'x'}, 'coefficients',{'A','B','K','L','n'});
f=fit(x,y,g,'StartPoint', [53.07, 0.003612, 0.139, 0.0002939, 2.454], 'Lower', [0 0 0.1 0 0 ],'MaxIter',100000);
plot(f)
hold on
scatter(x,y)
问题在于它会抛出一个不符合实验数据的曲线。
任何人都可以向我解释原因吗?如何获得符合数据的曲线?
答案 0 :(得分:0)
当我拟合您的发布数据和没有参数界限的方程时,拟合方程与原始数据的关系图没有给出您报告的问题的可视指示。也许这个问题在某种程度上与参数边界有关,如果是这样的话,当你无限制地适应时,你将得到与我获得的结果类似的结果。参数界限之一可能导致观察到的困难。为了比较,这里是我在无界限拟合时获得的参数值和拟合统计量:
A = -4.6348799797589422E+00
B = -8.5030471461837072E-03
K = -2.3151367681587254E-01
L = 5.1192051372512604E-01
n = 8.5896339221116724E-01
Degrees of freedom (error): 13
Degrees of freedom (regression): 4
Chi-squared: 0.129575842219
R-squared: 0.999684934083
R-squared adjusted: 0.999587990724
Model F-statistic: 10312.051735
Model F-statistic p-value: 1.11022302463e-16
Model log-likelihood: 18.863852459
AIC: -1.540428051
BIC: -1.2931025627
Root Mean Squared Error (RMSE): 0.0848449049798
A = -4.6348799797589422E+00
std err: 2.21395E+00
t-stat: -3.11497E+00
p-stat: 8.20677E-03
95% confidence intervals: [-7.84937E+00, -1.42039E+00]
B = -8.5030471461837072E-03
std err: 1.21952E-07
t-stat: -2.43489E+01
p-stat: 3.13238E-12
95% confidence intervals: [-9.25748E-03, -7.74861E-03]
K = -2.3151367681587254E-01
std err: 4.48642E-01
t-stat: -3.45642E-01
p-stat: 7.35141E-01
95% confidence intervals: [-1.67855E+00, 1.21552E+00]
L = 5.1192051372512604E-01
std err: 3.36712E-01
t-stat: 8.82213E-01
p-stat: 3.93682E-01
95% confidence intervals: [-7.41674E-01, 1.76551E+00]
n = 8.5896339221116724E-01
std err: 7.71803E-02
t-stat: 3.09187E+00
p-stat: 8.57996E-03
95% confidence intervals: [2.58784E-01, 1.45914E+00]
Coefficient Covariance Matrix
[ 2.22119894e+02 -5.17965896e-02 8.95871374e+01 -7.83675558e+01
-3.62713522e+01]
[ -5.17965896e-02 1.22351509e-05 -1.99822391e-02 1.74993754e-02
8.05904780e-03]
[ 8.95871374e+01 -1.99822391e-02 4.50111094e+01 -3.89773831e+01
-1.86449684e+01]
[ -7.83675558e+01 1.74993754e-02 -3.89773831e+01 3.37814021e+01
1.61229511e+01]
[ -3.62713522e+01 8.05904780e-03 -1.86449684e+01 1.61229511e+01
7.74329075e+00]