Nonlinear Curve Fitting
Fit a realistic enzyme-kinetics dataset with SciPy rather than a nearly perfect synthetic curve. The default Michaelis-Menten model estimates a saturation rate and half-saturation constant, while worksheet controls select the model and prediction interval used by the Python for Excel notebook.
Result preview
For the supplied noisy observations, the default Michaelis-Menten fit produces approximately Vmax = 91.927 µmol/min, Km = 3.384 mM, RMSE = 0.844 µmol/min, R² = 0.998585, parameter standard errors of about 1.139 and 0.129, and a covariance condition number of about 363.
What this template does
- Reads measured substrate concentration and reaction-rate observations from Excel.
- Fits either Michaelis-Menten or power-law parameters with bounded
scipy.optimize.curve_fit. - Calculates RMSE, R², small-sample-corrected AIC (AICc), parameter standard errors, and covariance conditioning.
- Builds covariance-based prediction intervals and residual diagnostics.
- Publishes fit tables plus reusable point-prediction and prediction-interval functions back to Excel.
Why Python
Nonlinear parameter estimation, covariance diagnostics, interval calculations, and residual visualization are substantially easier to express and audit with SciPy and NumPy than with spreadsheet helper columns and Solver configuration. SciPy also documents important caveats around covariance reliability and conditioning that the template surfaces directly. See the scipy.optimize.curve_fit documentation.
Try it live
Edit a measured rate, add observations in the prepared input area, change Model between Michaelis-Menten and Power law, or change the worksheet prediction interval. The fitted curve, diagnostics, point predictions, and prediction intervals all recompute from the same controls.
Operating workflow
Author: a technical analyst or engineer maintains the candidate equations, fitting/diagnostic logic, validation cases, and published prediction function.
Workbook user: a scientist or process engineer updates observations, selects the approved model and interval, then reviews fitted parameters, diagnostics, and worksheet predictions without editing the fitting code.
When this becomes a repeated review tool, the author can save the notebook to open in App mode and validate the workbook with its intended operator. App mode changes the visible authoring surface, not source availability.
Download the Excel template
Inputs and assumptions
Observations!A4:B24 provides a bounded input area for up to 20 substrate/rate observations; blank or nonnumeric rows are ignored. D4:E6 contains two durable fit controls: model choice and prediction interval. The model cell uses an Excel dropdown to prevent unsupported labels. The default model is:
rate = Vmax × substrate / (Km + substrate)
The interval calculation treats residual errors as independent with roughly constant variance and uses a local-linearization approximation based on the fitted parameter covariance.
Notebook implementation
The Python for Excel notebook binds the same observations and worksheet controls, computes the same fit, then adds a two-panel visual diagnosis and publishes a live predict function:
inputs = bf.inputs(
observations=bf.ref("Observations!A4:B24", headers=True),
controls=bf.ref("Observations!D4:E6", headers=True),
)
parameters, covariance = curve_fit(...)
bf.publish(
outputs={"summary": summary, "detail": detail},
functions={"predict": predict, "predict_interval": predict_interval},
)How the calculation/model works
Nonlinear curve fitting estimates parameters for a chosen function so its predictions are close to observed data. For observations y and model predictions f(x, parameters), nonlinear least squares minimizes the sum of squared residuals. The canonical workbook fits the Michaelis-Menten saturation model, y = Vmax × x / (Km + x). Vmax is the asymptotic response and Km is the x-value at half that response.
curve_fit minimizes squared residuals to estimate the selected nonlinear parameters. The template then calculates residual variance, RMSE, R², AICc, standard errors from the returned covariance matrix, and numpy.linalg.cond(covariance) as a quick identifiability diagnostic. AICc applies the finite-sample correction 2k(k+1)/(n-k-1) to AIC. Prediction intervals combine local mean-response variance with residual variance. For Power law, the initial scale and exponent come from a log-linear fit rather than depending on worksheet row order.
Validation / expected results
For the canonical Michaelis-Menten model:
| Check | Expected value |
|---|---|
| Vmax | 91.926508 |
| Vmax SE | 1.139245 |
| Km | 3.384195 |
| Km SE | 0.128541 |
| RMSE | 0.843683 |
| R² | 0.998585 |
| AICc | 2.940 |
| Covariance condition | 362.80 |
| Prediction at 8 mM | 64.599389 |
| 95% prediction interval at 8 mM | 62.17 – 67.03 |
The offline validation gate executes the canonical notebook.py against the generated workbook, checks BF.OUTPUT and BF.FUNCTION expectations, and verifies scenarios for Power law, whole-number percentage input, an added observation, zero substrate under Michaelis-Menten, and nonnumeric-row filtering.
Limitations
A high R² does not prove that Michaelis-Menten or any other candidate model is scientifically correct. The covariance and derived intervals are local approximations and can become unreliable when parameters are weakly identified or the covariance matrix is poorly conditioned. Predictions outside the measured concentration range are extrapolations. For formal inference, validate residual assumptions and use uncertainty methods appropriate to the experiment.
When to use this approach
Use nonlinear curve fitting when the functional form has scientific or operational meaning and the parameters themselves matter. If the primary goal is flexible prediction without a defensible functional form, consider a broader regression or machine-learning approach instead.