【问题标题】:Nonlinear fits in Octave非线性拟合 Octave
【发布时间】:2018-11-19 09:11:38
【问题描述】:

目前我正在使用 GNU Octave 的 'optim' 包中的 nonlin_curvefit 函数来将数据与 .但是这次我确实也需要返回参数的不确定性来确定拟合的质量。在阅读了我使用函数curvefit_stat 绑定的文档后。 但是,每当我使用此功能时遇到错误时,我都无法理解错误消息。我正在使用 Ubuntu 18.04 的默认存储库中的 Octave 4.2.2。

下面的独立最小示例和错误消息。开始参数init_cvg 通常会产生良好的结果,而使用init_dvg 通常会导致拟合不佳:

1;

x = linspace(-2*pi, 2*pi, 600);
ydata = 3.4*sin(1.6*x) + rand(size(x))*1.3;

f = @(p, x) p(1)*sin(p(2).*x);
function y  = testfun(p ,x)
  y = p(1).*sin(p(2).*x);
endfunction

init_cvg = [1; 1.1];
init_dvg = [1; 1.0];

[pc, mod_valc, cvgc, outpc] = nonlin_curvefit(f, init_cvg, x, ydata);
[pd, mod_vald, cvgd, outpd] = nonlin_curvefit(f, init_dvg, x, ydata);


hold off
plot(x, yd, "b.");
hold on;
plot(x, mod_valc, "r-");
plot(x, mod_vald, "color", [0.9 0.4 0.3]);

settings = optimset("ret_covp", true);
covpc = curvefit_stat(f, pc, x, ydata, settings);
covpd = curvefit_stat(f, pd, x, ydata, settings);

puts("sqrt(diag(covpc))")
sqrt(diag(covpc))

puts("sqrt(diag(covpd))")
sqrt(diag(covpd))

当我使用f 作为模型函数时会出现第一条错误消息,而当我使用testfun 时会出现第二条错误消息:

>> curvefit_stat_TEST
error: label of objective function must be specified
error: called from
    __residmin_stat__ at line 566 column 7
    curvefit_stat at line 56 column 7
    curvefit_stat_TEST at line 25 column 7
>> curvefit_stat_TEST
error: 'p' undefined near line 8 column 7
error: called from
    testfun at line 8 column 5
    curvefit_stat_TEST at line 25 column 7
>>

有人可以确认这个错误吗?

我将不胜感激。

【问题讨论】:

    标签: octave data-fitting


    【解决方案1】:

    我发现了问题。 我需要将“abjf_type”、“wls”作为参数添加到 optimset。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 2020-07-21
      • 1970-01-01
      • 2019-03-15
      • 2021-05-08
      • 1970-01-01
      • 2021-07-23
      相关资源
      最近更新 更多