It is a core skill in science and engineering (and in other fields such as data science) to be able to fit functions (straight lines, Gaussians, etc) to noisy data, including being able to reliably estimate the uncertainty in the values of the fit parameters. You can download, edit and run (or run online) these notebooks to fit to data. You can also edit them to fit other functions, or to data in other forms. But please NOTE that all ways to estimate uncertainties/errors make assumptions, so please don't fit without bearing that in mind.

The INTRO notebook is a self-contained Python notebook to fit a straight line (slope and intercept) to data, which includes standard error uncertainty estimates. Fitting is via least squares. It has links to webpages etc to explain where the math formulas needed to fit and to estimate uncertainties come from. Note that all fitting and uncertainty estimation methods make assumptions.

The INTRO notebook reads in and fits to the data in the text file "lin_fit_input_data.txt". You need to save both the notebook (.ipynb) and the text file to the same directory, then run the notebook.

The FULL version also shows how to use both the bootstrap and the jackknife uncertainty estimates.

You probably want to start with the INTRO version.

These notebooks fit power laws and Gaussian functions to data

Clones Terminal Edit
Showing 7 notebooks