Weighted Least Square Fit regarding equal parts of the xaxis

3 ビュー (過去 30 日間)
michael fechter
michael fechter 2020 年 8 月 10 日
コメント済み: michael fechter 2020 年 8 月 10 日
Regarding a symmetric dataset of x (Temperature) and y (logarithmic of Pressure), I use a 7-parameter (Param) equation (Antoine) to fit these data points, regarding given lower and upper bounds (lb and ub):
lb = [-50000 -50000 -50000 -50000 -50000 -50000 -50000];
ub = [+50000 +50000 +50000 +50000 +50000 +50000 +50000];
options = optimoptions('lsqcurvefit', 'MaxIterations', 400000,...
'StepTolerance', 1e-15,...
'OptimalityTolerance', 1e-15,...
'Display', 'off',...
'FunctionTolerance', 1e-15,...
'MaxFunctionEvaluations',150000);
Antoine = @(Param,x)(Param(1)+(Param(2)./(x+Param(3)))+Param(4).*x + Param(5).*log(x)+Param(6).*(x.^Param(7)));
Param = lsqcurvefit(Antoine, Param, x, y, lb, ub, options); %antoine parameters
Regarding the dataset of x and y, the datapoints are not equally distributed over the x-range, having a lot more ydata at small xdata-values.
How to weight the least square solver to consider equally the xaxis divided in equally sized sections, to avoid overweighting the ydata at small xdata-values?

採用された回答

John D'Errico
John D'Errico 2020 年 8 月 10 日
You can't directly supply weights as an option to laqcurvefit.
Better is to use lsqnonlin for this, since you return the residuals.
Create a vector for the weights I've called it w here. Small, where you want the weight for a point to be small.
AntoineW = @(Param,x,y,w) w.*(y - (Param(1)+(Param(2)./(x+Param(3)))+Param(4).*x + Param(5).*log(x)+Param(6).*(x.^Param(7))));
Param0 = [... stuff ...]
ParamEst = lsqnonlin(@(Param) Antoine(Param,x,y,w), Param0, lb, ub, options); %antoine parameters
As you should see, this scales the residuals in that area by an amount you can define in the vector w.
Set your options up for lsqnonlin. By the way, setting the tolerances that tiny can be of little real value. These algorithms tend to be quadratically convergent near the solution. But setting really tiny tolerances may just make the code work very hard at the end, wasting a lot of time for no gain as it tries to refine the least significant bits of the result.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLeast Squares についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by