MATLAB Linear Least Squares Fit with Error Bars: A MATLAB Tutorial

Click For Summary
To perform a linear least squares fit with data points that have associated error bars, a weighted least squares fit is necessary. This method involves weighting each data point by the inverse of its variance, allowing for more accurate fitting that accounts for the uncertainty in the measurements. In MATLAB, the LSCOV function is recommended for executing weighted least squares regression, making it a suitable tool for this type of analysis.
Simfish
Gold Member
Messages
811
Reaction score
2
With MATLAB or something. Basically, I just have a bunch of data points where I should do a linear least squares fit, but each of the points have error bars around them.
 
Physics news on Phys.org


Simfish said:
With MATLAB or something. Basically, I just have a bunch of data points where I should do a linear least squares fit, but each of the points have error bars around them.

What you would need is a "weighted least squares fit".
The points must be weighted by 1/variance.

According to google:
In MATLAB, the LSCOV function can perform weighted-least-square regression.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K