Skip to main content

curvefit-stats logo

curvefit-stats

Documentation · Quickstart

Statistical inference for SciPy-style nonlinear models, plus shared-parameter fitting and errors-in-variables regression. Use ordinary functions written as model(x, *parameters) with NumPy arrays.

The package contains exactly two functional modules:

  • curvefit_stats.inference:

    • bands, likelihood diagnostics, parameter summaries
    • profile likelihood, bootstrap covariance, collinearity diagnostics,
    • bound-aware covariance, and derived-quantity propagation.
  • curvefit_stats.estimators:

    • GlobalFitGroup
    • eiv_curve_fit.

Installation

Install curvefit-stats directly from PyPI:

pip install curvefit-stats

The SciPy upper limit applies to the EIV backend: scipy.odr is deprecated in SciPy 1.17 and removed in 1.19. EIV calls on deprecated versions emit a FutureWarning; calls outside the supported range fail explicitly. See the ODR compatibility notes.

Quick start: concentration decay

Fit concentration in mg/L against time in hours with C(t) = amplitude * exp(-rate * t). This example assumes independent Gaussian measurement errors with an unknown common variance.

import numpy as np
from scipy.optimize import curve_fit
from curvefit_stats import generate_error_bands, fit_summary, audit_fit


def decay(time, amplitude, rate):
    return amplitude * np.exp(-rate * time)


rng = np.random.default_rng(2026)
time = np.linspace(0, 5, 45)
concentration = decay(time, 3.0, 0.7) + rng.normal(0, 0.08, time.size)
popt, pcov = curve_fit(decay, time, concentration, p0=[2.5, 0.5])

grid = np.linspace(0, 5, 101)
lower, upper = generate_error_bands(
    decay, grid, popt, pcov, concentration, x_fit=time,
)
print(fit_summary(decay, time, concentration, popt, pcov))
print(audit_fit(decay, time, concentration, popt))

The bands have approximate pointwise 95% confidence coverage for the mean. They do not cover an entire curve simultaneously or include the noise of a new measurement. The original fitting sample determines degrees of freedom, not grid. For known absolute Gaussian errors, fit with absolute_sigma=True and choose reference="normal" for bands.

Executable workflows

examples/workflows.py provides seeded, independently selectable examples. Run PYTHONPATH=src python examples/workflows.py NAME.

Name Workflow Main feature
confidence Nonlinear decay fitting and mean-concentration bands generate_error_bands
intervals Mean confidence versus future-observation prediction generate_error_bands
diagnostics Gaussian fit diagnostics and AIC/BIC comparison audit_fit
summary R-inspired approximate nonlinear parameter table fit_summary
profile Asymmetric Michaelis–Menten profile errors profile_likelihood_errors
bootstrap Residual-bootstrap covariance and percentile interval bootstrap_curve_fit
collinearity Unsaturated kinetics and local parameter dependence collinearity_diagnostics
bounds Decay baseline at an active lower bound robust_bounded_pcov
propagation Concentration and half-life uncertainty propagate_uncertainty
global Shared decay rate, separate initial concentrations GlobalFitGroup
eiv Uncertain time and concentration measurements eiv_curve_fit

The collinearity and bounds examples intentionally emit statistical warnings; EIV also emits its compatibility warning on SciPy 1.17–1.18. Numerical output can vary slightly across NumPy/SciPy versions. Fixed seeds make each experiment reproducible within an environment, without requiring bit-for-bit agreement across platforms.

Choose the statistical convention explicitly

sigma supplies standard deviations, not variances, for scalar/vector errors. A two-dimensional sigma supplies the full observation covariance. With absolute_sigma=True, these are known absolute error scales. With False, they supply relative weighting, and one unknown common variance multiplier is fitted. These choices affect covariance scaling and likelihood parameter counting.

A covariance array does not retain its estimator, noise model, constraints, or reference distribution. Preserve that context. Ordinary response-only likelihood methods cannot automatically become ODR methods; conditional covariance at active bounds is not full marginal uncertainty; and empirical bootstrap covariance does not establish a Student-t pivot.

Read the user guide for equations, assumptions, failure handling, and workflow choices. The API reference is generated directly from Python source and NumPy-style docstrings on every site build. A generated offline snapshot is retained for repository readers. The integration guide explains covariance projection between modules, and the stress-test report records independent numerical validation and remaining scientific limitations.

Reproducible development and packaging

The development guide describes the hash-locked Python 3.12 development environment, strict quality checks, compatibility matrix, wheel/source builds, and isolated installation checks. py.typed is included in both distributions. Development tools live in optional extras and are not base runtime dependencies. CI tests built wheels and direct source-distribution installation; it does not publish releases.

The pre-release scientific review records independently reproduced defects, regression fixes, scientific limitations, and release gates.

Author and Maintainer

Abhinav Mishra — Computational Biologist & Scientific Software Developer

curvefit-stats was conceived and developed by Abhinav Mishra to make statistical inference and uncertainty quantification more accessible, reproducible, and reliable for scientists using SciPy's nonlinear optimization tools.

Contributions, bug reports, and scientific discussions are welcome.

Acknowledgments

curvefit-stats is built on the scientific Python ecosystem, particularly NumPy for numerical computing and SciPy for nonlinear optimization, statistical distributions, and numerical linear algebra.

We gratefully acknowledge the NumPy and SciPy developers and contributors for their foundational open-source work.

curvefit-stats is an independent project and is not officially affiliated with or endorsed by NumPy or SciPy.

License

The Python source code and executable examples in curvefit-stats are licensed under the MIT License.

Original documentation and illustrations are licensed under CC BY 4.0, unless otherwise noted.

Copyright © 2026 Abhinav Mishra.

Third-party materials retain their respective licenses. See THIRD_PARTY_NOTICES.md.

Metadata

Release files for curvefit-stats 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for curvefit-stats 0.1.1
File Size Uploaded
curvefit_stats-0.1.1.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for curvefit-stats 0.1.1
File Interpreter ABI Platform
curvefit_stats-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / curvefit_stats-0.1.1.tar.gz

Download URL curvefit_stats-0.1.1.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
e290c840b2239317b737dc56f09dd3675e1dfcd07274e47d314ac65dae1a818c
BLAKE2b-256 checksum
How to use checksums
04eb1717d5c5c9cbd7c5c2249093c8b719feb0a40c0f6f0fc864f5f4a2b97552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / curvefit_stats-0.1.1-py3-none-any.whl

Download URL curvefit_stats-0.1.1-py3-none-any.whl
Size 49.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c1e79930a46a717f0b2678cb30b202b8f17d8eb50bbe28c3dc5c6e543145b03
BLAKE2b-256 checksum
How to use checksums
b634809e4279faa887e8629b310d426a654f856cca48aa4977b105cd22105c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page