在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):JAAdrian/MatlabRobustNonlinLsq开源软件地址(OpenSource Url):https://github.com/JAAdrian/MatlabRobustNonlinLsq开源编程语言(OpenSource Language):MATLAB 100.0%开源软件介绍(OpenSource Introduction):MatlabRobustNonlinLsqMATLAB's function The downside is that This MATLAB function is intended to give the best of both worlds, i.e. combine methods of DependenciesThis function is tested in MATLAB R2016b but should scale to any modern MATLAB release. The function depends on the following toolboxes:
UsageConsider the following problem. We want to fit a function to data which stems from a square-root function with a scale and location parameter. The data is noisy and exhibits strong outliers. Let's see how ordinary and robust non-linear least squares perform in this situation. The example is taken from the provided demo file. % the model's true parameters
trueParams = [50, -0.7];
% create some noisy data using a square root function with 2 parameters and nasty noise
x = linspace(0, 20, 100);
modelFun = @(param, x) param(1)*sqrt(max(0, x + param(2)));
noise = 10*sin(x).^2 .* randn(size(x));
y = modelFun(trueParams, x) + noise;
% introduce outliers
y(11) = -300;
y(end) = 2000;
%%%% Fit the model %%%%
% make sure the parameters are within the following range
lb = [1, -inf];
ub = [inf, 10];
% initial guess
x0 = [1, -1];
% don't show infos from lsqcurvefit()
options = optimset(@lsqcurvefit);
options.Display = 'off';
% estimate parameters using ordinary and robust LSQ
estParamsOrdinary = lsqcurvefit(modelFun, x0, x, y, lb, ub, options);
estParamsRobust = robustlsqcurvefit(modelFun, x0, x, y, lb, ub, [], options);
figure;
hold on;
scatter(x, y, 'filled');
plot(x, modelFun(trueParams, x), 'k--', 'linewidth', 2);
plot(x, modelFun(estParamsOrdinary, x), 'linewidth', 2');
plot(x, modelFun(estParamsRobust, x), 'linewidth', 2);
hold off;
grid on;
legend(...
{'Noisy Data', 'True Regression', 'Ordinary non-lin LSQ', 'Robust non-lin LSQ'}, ...
'fontsize', 12 ...
); LicenseThe code is licensed under BSD 3-Clause license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论