Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python linear fitting with multiple error bars

I am fitting some data with a linear fit. I want to weight the error bars. Up to this point, I have been using bulldogs fitting.py. Their linear_fit makes weighted linear regressions very easy. Unfortunately, the data I'm working with has error in both the X and Y directions.

I was wondering how, both practically (in Python) and theoretically (in statistical terms), this would be done.

like image 460
pirtle Avatar asked Aug 01 '12 02:08

pirtle


1 Answers

There's a couple of choices:

  1. scipy.optimize.leastsq (for the total least squares)
  2. scipy.odr (for Deming regression).

Both of these solutions will account for independent error in X and Y directions (the scld array in odr).

like image 106
Andy Hayden Avatar answered Oct 29 '22 17:10

Andy Hayden