Non-linear curve fitting in SciPy: Basics
Least-squares and how to do it Python
Non-linear curve fitting (or non-linear parametric regression)is a fundamental part of the quantitative analysis performed in multiple scientific disciplines. The main idea is that we know (or assume) the model that describes an observed data. For example, lets say we collected data that looks like this:
It would seem reasonable to assume that this curve is described by an exponential decay function of the form `S= a * exp(-xdata/b)`. Then, how we test that this assumption is correct and estimate a and b ?.
We find the values for a and b that minimize the square of the residuals between the predicted data assuming the exponential model and the observed data. In the next section I present a python code to perform non-linear curve fitting on a simulated curve.
Python Code for non-linear curve fitting