Hogg, Bovy & Lang (2010) [astrobites review] is a great paper on how to fit a straight line to your data, with proper accounting for scatter, uncertainty, and outliers. Following on from this work, the following tutorials demonstrate good fitting techniques in python using emcee:
- Fitting a straight line model to data with 1-d uncertainties (Dan Foreman-Mackey)
- Fitting a sine curve model to data (APW) -- Coming Soon!
- Fitting a straight line model to data with intrinsic scatter (BW) -- Coming Soon!