Skip to main content

Documentation Status PyPI Zenodo GithubCI MIT License

Numerical differentiation of noisy time series data in python

derivative is a Python package for differentiating noisy data. The package showcases a variety of improvements that can be made over finite differences when data is not clean.

Want to see an example of how derivative can help? This package is part of PySINDy (github.com/dynamicslab/pysindy), a sparse-regression framework for discovering nonlinear dynamical systems from data.

This package binds common differentiation methods to a single easily implemented differentiation interface to encourage user adaptation. Numerical differentiation methods for noisy time series data in python includes:

  1. Symmetric finite difference schemes using arbitrary window size.

  2. Savitzky-Galoy derivatives (aka polynomial-filtered derivatives) of any polynomial order with independent left and right window parameters.

  3. Spectral derivatives with optional filter.

  4. Spline derivatives of any order.

  5. Polynomial-trend-filtered derivatives generalizing methods like total variational derivatives.

  6. Kalman derivatives find the maximum likelihood estimator for a derivative described by a Brownian motion.

  7. Kernel derivatives smooth a random process defined by its kernel (covariance).

from derivative import dxdt
import numpy as np

t = np.linspace(0,2*np.pi,50)
x = np.sin(x)

# 1. Finite differences with central differencing using 3 points.
result1 = dxdt(x, t, kind="finite_difference", k=1)

# 2. Savitzky-Golay using cubic polynomials to fit in a centered window of length 1
result2 = dxdt(x, t, kind="savitzky_golay", left=.5, right=.5, order=3)

# 3. Spectral derivative
result3 = dxdt(x, t, kind="spectral")

# 4. Spline derivative with smoothing set to 0.01
result4 = dxdt(x, t, kind="spline", s=1e-2)

# 5. Total variational derivative with regularization set to 0.01
result5 = dxdt(x, t, kind="trend_filtered", order=0, alpha=1e-2)

# 6. Kalman derivative with smoothing set to 1
result6 = dxdt(x, t, kind="kalman", alpha=1)

# 7. Kernel derivative with smoothing set to 1
result7 = dxdt(x, t, kind="kernel", sigma=1, lmbd=.1, kernel="rbf")

Contributors:

Thanks to the members of the community who have contributed!

Jacob Stevens-Haas

Kalman derivatives #12, and more!

References:

[1] Numerical differentiation of experimental data: local versus global methods- K. Ahnert and M. Abel

[2] Numerical Differentiation of Noisy, Nonsmooth Data- Rick Chartrand

[3] The Solution Path of the Generalized LASSO- R.J. Tibshirani and J. Taylor

[4] A Kernel Approach for PDE Discovery and Operator Learning - D. Long et al.

Citing derivative:

The derivative package is a contribution to PySINDy; this work has been published in the Journal of Open Source Software (JOSS). If you use derivative in your work, please cite it using the following reference:

Kaptanoglu et al., (2022). PySINDy: A comprehensive Python package for robust sparse system identification. Journal of Open Source Software, 7(69), 3994, https://doi.org/10.21105/joss.03994

@article{kaptanoglu2022pysindy,
        doi = {10.21105/joss.03994},
        url = {https://doi.org/10.21105/joss.03994},
        year = {2022},
        publisher = {The Open Journal},
        volume = {7},
        number = {69},
        pages = {3994},
        author = {Alan A. Kaptanoglu and Brian M. de Silva and Urban Fasel and Kadierdan Kaheman and Andy J. Goldschmidt and Jared Callaham and Charles B. Delahunt and Zachary G. Nicolaou and Kathleen Champion and Jean-Christophe Loiseau and J. Nathan Kutz and Steven L. Brunton},
        title = {PySINDy: A comprehensive Python package for robust sparse system identification},
        journal = {Journal of Open Source Software}
        }

Release files for derivative 0.6.3

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

Source distribution (sdist)

Source distribution for derivative 0.6.3
File Size Uploaded
derivative-0.6.3.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for derivative 0.6.3
File Interpreter ABI Platform
derivative-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.1 kB

Release files / derivative-0.6.3.tar.gz

Download URL derivative-0.6.3.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
72e7fd56e92665f939b5449c4b9ceea88fdf02eda7378cf0a3e961ab0df58181
BLAKE2b-256 checksum
How to use checksums
c5e879b4127aa6b797b7a74fa20635229e2d97af384fb1950d25700a2fce13a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.9.19 Linux/6.5.0-1025-azure

Release files / derivative-0.6.3-py3-none-any.whl

Download URL derivative-0.6.3-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e121926a21e13a5ab1db07e10e26a5e805494a1255eac032c2fba309547e64c9
BLAKE2b-256 checksum
How to use checksums
cd3a6a615fa5a1fb1e11f0ad41febedea907a2f20a310f7a9fc5b3a16639c2ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.9.19 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

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