Git Product home page Git Product logo

whittaker-eilers-smoother's Introduction

Whittaker-Eilers smoother in Python

Here's an implementation in Python-numpy-scipy of the Whittaker-Eilers smoother described in: P. H. C. Eilers, "A perfect smoother", Anal. Chem. 2003, 75, 3631-3636 (doi:10.1021/ac034173t). Use of specific sparse matrix routines makes the smoother fast and memory-efficient. The present implementation only covers evenly-spaced data (i.e. data sampled at equal distances) without missing values.

The original Matlab program by Eilers uses the sparse Cholesky solver for solving the matrix equation involved in the smoothing procedure, but since a sparse Cholesky solver is not available in the 'scipy' sparse matrix library, we chose the sparse LU-decomposition based solver instead ('scipy.sparse.linalg.splu'). Our Python implementation was tested with the data provided with the original publication, and gave identical smoothing results. The test is included here as an example script.

The example script demonstrates how the smoothing routine is used. The only parameter that needs to be tuned (manually, for now) is lmbd ('λ' in the Eilers paper), which determines the strength of the smoothing. Note that lmbd needs tuning over several orders of magnitude (10, 100, 1000, ...). As an optional second parameter, the default 2nd-order smoother (d = 2) will work fine for almost all signals.

We have used the Whittaker-Eilers smoother in our recent work, e.g. J. Midelet et al., ChemPhysChem 2018, 19, 827-836. doi:10.1002/cphc.201701228

It is easy and intuitive to use, often gives better results faster than the venerable Savitsky-Golay smoother, and far better results than boxcar-smoothing.

This impementation is distributed under the CeCILL-B license (a BSD-like license). See: http://www.cecill.info/

Many thanks go to Simon Bordeyne who pioneered a first (non-sparse) version of the smoother in Python.

Suggestions for further work

  • Add support for missing values and unevenly spaced data, following the indications in Eilers' paper.
  • Explore 'auto-tuning' of the λ parameter, as explained in that same paper, and how this would best be implemented.

whittaker-eilers-smoother's People

Contributors

mhvwerts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.