NEURON Note #28


Goals: Some Notes about Curve Fitting


Introduction:

Curve fitting is a very important tool to find time constants in biopysical processes. Here, I explored the consequences of fitting a curve with inconsistant functions. First, I tried to fit second or third power exponential decay curves with a first power exponential decay function. Next, I tried to fit first power exponential decay curves with second or third power exponential decay functions.


Notes about methods:

curve_fit() in scipy will be used to fit curves. Exponential decay function is generated accoding to y = 1 - exp(-x / tau). Tau is from 1 ms to 20 ms. y(x)  to the power of 2 to 3 are generated.


Results:

Fit second power exponential decay curves with first power exponential decay function

In this scenario, there is a second power exponential decay curve, which I tried to fit it with a single power exponential decay function. The result tau is about 1.4 longer than the tau in the second power exponential decay curve. If someone noticed that the actual function is a second power exponential decay function, he or she can correct the tau by divid it with the square root of 2.

The period for fitting is 100 ms.The period for fitting is 200 ms.
Tau = 20
Tau = 20 ms
Black: First power exponential decay
Blue: Second power exponential decay
Red: First power exponential decay fit to the blue trace
200 ms
Tau = 20 ms
Tau
Black: First power exponential decay
Red: Second power exponential decay fitted by single exponential decay.
Green: Corrected tau
200 ms

The period for fitting must be 10 times longer than tau to get a good fit.
When the period for fitting is too short, the estimated tau is longer than the actual tau.


Fit third power exponential decay curves with first power exponential decay function

The period for fitting is 100 ms.The period for fitting is 200 ms.
third power
Tau = 20 ms
Black: First power exponential decay
Blue: Third power exponential decay
Red: First power exponential decay fit to the blue trace
200 ms
Tau = 20 ms
Tau 200 ms

The period for fitting must be 10 times longer than tau to get a good fit.
When the period for fitting is too short, the estimated tau is longer than the actual tau.


Fit first power exponential decay curves with second power exponential decay function

In this scenario, we have a single power exponential decay curve, but we try to fit it with a second power exponential decay function. The result tau is shorter than the tau in the single power exponential decay. To convert the fitted tau to the tau of the first power exponential decay function, multiply each tau with 1.23.

The period for fitting is 100 ms.The period for fitting is 20 ms.
Curves
Tau = 20 ms
Curves
Tau = 20 ms
Plot
Second Power Fit * 1.23 = First Power
Tau

The fitting period must be at least four times longer than the actual tau to get a good fit.


Fit first power exponential decay curves with third power exponential decay function

In this scenario, we have a first power exponential decay curve, but we try to fit it with a third power exponential decay function. The result tau is shorter than the tau in the first power exponential decay curve. To convert the fitted tau to the tau of the first power exponential decay function, multiply each tau with 1.31.

The period for fitting is 100 ms.The period for fitting is 20 ms.
Curves
Tau = 20 ms
Curves
Tau = 20 ms
Tau
Second Power Fit * 1.31 = First Power
Tau

The fitting period must be at least four times longer than the actual tau to get a good fit.