Growth/decay curve fitting
This calculator fits simple models to time-series data \((t, y)\) and reports best-fit parameters, fit quality, and short forecasts.
Use it for quick lab-style trend analysis (not as a full biological mechanism model).
What you need to provide
Data format
- Each row should contain two numbers: time \(t\) and measurement \(y\).
- Units are up to you (minutes, hours, days, etc.)—just be consistent.
- Rows are treated as \((t_i, y_i)\) after cleaning. Extra text is ignored when possible.
Exponential models require \(y > 0\). If any \(y \le 0\), the log transform (and often the exponential model itself) becomes invalid.
When the two models make sense
A quick diagnostic: if a plot of \((t, \ln(y))\) looks roughly linear, exponential is plausible.
Model 1: Linear fit
The linear model is
\(\;y = a + b \cdot t\).
Here, \(a\) is the intercept (value near \(t = 0\)) and \(b\) is the slope (change in \(y\) per 1 unit of time).
\[
\begin{aligned}
\bar{t} &= \frac{1}{n}\sum_{i=1}^{n} t_i,
\qquad
\bar{y} = \frac{1}{n}\sum_{i=1}^{n} y_i \\
S_{tt} &= \sum_{i=1}^{n}(t_i-\bar{t})^2,
\qquad
S_{ty} = \sum_{i=1}^{n}(t_i-\bar{t})(y_i-\bar{y}) \\
b &= \frac{S_{ty}}{S_{tt}},
\qquad
a = \bar{y} - b \cdot \bar{t}
\end{aligned}
\]
If all \(t_i\) are identical, then \(S_{tt}=0\) and the slope cannot be computed. You need variation in time.
Model 2: Exponential fit
The exponential model is
\(\;y = A \cdot e^{k \cdot t}\).
Here, \(A\) is the scale at \(t=0\) (when that interpretation is meaningful),
and \(k\) controls the growth/decay rate:
\(k>0\) for growth, \(k<0\) for decay.
Linearized (log) fit
Taking the natural log transforms exponential data into a line:
\[
\begin{aligned}
y &= A \cdot e^{k \cdot t} \\
\ln(y) &= \ln(A) + k \cdot t
\end{aligned}
\]
Define \(z_i = \ln(y_i)\). Then fit the line \(z = \ln(A) + k \cdot t\) by least squares:
\[
\begin{aligned}
k &= \frac{\sum (t_i-\bar{t})(z_i-\bar{z})}{\sum (t_i-\bar{t})^2} \\
\ln(A) &= \bar{z} - k \cdot \bar{t} \\
A &= e^{\ln(A)}
\end{aligned}
\]
This method requires \(y_i>0\) for all points (because \(\ln(y_i)\) must exist).
Direct fit on the original \(y\) scale
Instead of logging, we can fit the exponential curve by minimizing the sum of squared errors in the original units:
\[
\begin{aligned}
\mathrm{SSE}(A,k) &= \sum_{i=1}^{n}\left(y_i - A \cdot e^{k \cdot t_i}\right)^2
\end{aligned}
\]
For a fixed \(k\), the best \(A\) has a closed form:
\[
\begin{aligned}
A(k) &= \frac{\sum_{i=1}^{n} y_i \cdot e^{-k \cdot t_i}}{\sum_{i=1}^{n} e^{-2k \cdot t_i}}
\end{aligned}
\]
Then the calculator searches numerically for \(k^\*\) that minimizes \(\mathrm{SSE}(k)=\mathrm{SSE}(A(k),k)\), and uses \(A=A(k^\*)\).
Direct fitting often behaves better when measurement noise is roughly constant in \(y\). The log fit tends to emphasize relative (percent) errors.
Fit quality: \(r^2\), SSE, and RMSE
The calculator reports fit quality computed on the original \(y\) scale (even for the linearized exponential fit).
\[
\begin{aligned}
\hat{y}_i &= \hat{y}(t_i) \\
\mathrm{SSE} &= \sum_{i=1}^{n}(y_i-\hat{y}_i)^2 \\
\mathrm{SST} &= \sum_{i=1}^{n}(y_i-\bar{y})^2 \\
r^2 &= 1 - \frac{\mathrm{SSE}}{\mathrm{SST}} \\
\mathrm{RMSE} &= \sqrt{\frac{\mathrm{SSE}}{n-2}}
\end{aligned}
\]
Interpretation tips:
- \(r^2\) near 1 means the model explains most variation in \(y\) across time (within the provided range).
- RMSE is in the same units as \(y\), so it is often easier to interpret in a lab setting.
- If \(n \le 2\), RMSE with \(n-2\) in the denominator is not meaningful.
Doubling time and half-life
For the exponential model \(y = A \cdot e^{k \cdot t}\), the time scale is:
\[
\begin{aligned}
\text{If } k &> 0:\quad T_{2} = \frac{\ln(2)}{k} \\
\text{If } k &< 0:\quad T_{1/2} = \frac{\ln(2)}{|k|}
\end{aligned}
\]
Practical meaning:
- Doubling time \(T_2\): how long it takes to multiply by 2 (growth).
- Half-life \(T_{1/2}\): how long it takes to divide by 2 (decay).
Forecasts and the “forecast band”
Forecast times are generated from your last observed time \(t_{\max}\) using a step size \(\Delta t\):
\[
\begin{aligned}
t_{\text{future},i} &= t_{\max} + i \cdot \Delta t \qquad (i=1,\dots,m) \\
\hat{y}(t) &=
\begin{cases}
a + b \cdot t, & \text{linear} \\
A \cdot e^{k \cdot t}, & \text{exponential}
\end{cases}
\end{aligned}
\]
The shaded “forecast band” is a simple heuristic:
it shows \(\hat{y}(t) \pm \mathrm{RMSE}\) in the forecast region.
This is not a formal confidence interval, and it does not account for parameter uncertainty.
Tip: If your time steps are uneven, leaving \(\Delta t\) blank lets the calculator estimate a typical step (based on median positive differences).
Common pitfalls and quick fixes
Exponential errors
- \(y \le 0\): log fit cannot run; exponential is usually inappropriate unless data are shifted by a justified baseline.
- \(k \approx 0\): the exponential behaves nearly constant; check if linear is more appropriate.
Data quality
- Too few points: results are unstable. Aim for at least 5–8 points when possible.
- Outliers: one extreme point can dominate the fit. Consider repeating measurements or checking for recording errors.
- Different units: mixing minutes and hours without converting will break interpretation.
A practical workflow:
- Start with the scatter plot on the original scale.
- If growth/decay looks multiplicative, enable the log-\(y\) view and check if points align roughly on a straight line.
- Compare linear vs exponential by \(r^2\) and RMSE, but also by whether the model makes biological sense for the time window.