How to do curve fitting on a data set with errors associated to each data point (y ± Δ y)

148 ビュー (過去 30 日間)
Thilini Dissanayake
Thilini Dissanayake 2019 年 2 月 26 日
編集済み: Boaz Zick 2022 年 4 月 20 日
I have a data set in the form x (independent variable), y ± Δy (dependent variable). As you can see there's an error associated with each data point in dependent variable. I want to do curve fitting for this data set and can you help me with how to do that.
I know how to use curve fitting tool box to fit a curve for a data set in the form x,y. But I don't know how to use matlab to do curve fitting when there's an error associated with each data point.
  3 件のコメント
SWATI BHARGAVA 2019 年 12 月 3 日
  • Once above is done, I finally want to find the standard deviation of the data in fitted curve as well.


回答 (3 件)

John D'Errico
John D'Errico 2019 年 2 月 26 日
編集済み: John D'Errico 2019 年 2 月 26 日
Since you have explicit bounds on y +/- deltay, you cannot just use simple weights. As well, you cannot use the curve fitting toolbox. Instead, you can set this up as an fmincon problem, with nonlinear constraints. Each data point will provide two nonlinear constraints, an upper and lower bound for the curve at each given point. This is much simpler of course if the problem is a linear one, since then you could use lsqlin instead with simple linear inequality constraints.
So, is your model linear in the parameters? I.e., any polynomial model, is linear in the parameters. So models like y = a0+a1*x, a0+a1*x+a2*x^2, etc. Each of those models are linear in the parameters, though they need not be linear in x.
Alternatively, a model like y=a0+a1*sin(a2*x) is linear in two of the parameters, but nonlinear in a2. This would take somewhat more effort to solve than the simple polynomial models I described, but it is still solvable. Other models, thus perhaps a1*exp(a2*x) wuld also have a solution method that would be pehaps most appropriate.
Now, perhaps you have no a-priori choice of model? In that case, a regression spline model probably makes sense. And I would point out that my SLM toolbox actually allows the suer to provide an explicit set of upper and lower bounds that can be used to constrain the curve at each data point.
The point is, the most appropriate solution method will depend on the model, but I don't know what model you have.

Ankit Labh
Ankit Labh 2020 年 1 月 20 日
I have exactly the same problem. I wanted to fit gaussian with all y values as y +- Delta_y. Considering the errors associated to y value, I still do not get the answer to do the fitting. If you get any answers, do post here.
Thank you very much

Boaz Zick
Boaz Zick 2022 年 4 月 20 日
編集済み: Boaz Zick 2022 年 4 月 20 日
I just found something that can maybe help you.
watch from 10:10.
Monte Carlo method
the idea is to add noise to your data to simulate alot of measurments that could have been made with your error in measurment, and then curve fit each one of those measurments, and check the mean and standart deviation of your coefficients.
here is an example for a linear fit, in order to fit other curves change fitlm and add coefficients as necessary.
a_lst=[a_coefficient]; %first value can be your curve fitting coefficients from ideal data points
b_lst=[]; %or left blank
for i = 1:rep
bd_coefficient = d_linear.Coefficients.Estimate(1);
ad_coefficient = d_linear.Coefficients.Estimate(2);
histogram (a_lst,100);

Community Treasure Hunt

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

Start Hunting!

Translated by