sablib
Loading...
Searching...
No Matches
savitzky_golay.h File Reference

Smoothing using Savitzky-Golay filter. More...

#include <stdexcept>
#include <vector>

Go to the source code of this file.

Functions

const std::vector< double > sablib::SavitzkyGolayCoefficients (const unsigned int n, const unsigned int polyorder, const unsigned derive=0, const double delta=1)
 Calculates the coefficients for a Savitzky-Golay filter.
const std::vector< double > sablib::SavitzkyGolay (const std::vector< double > &y, const unsigned int n, const unsigned int polyorder, const unsigned derive=0, const double delta=1)
 Performs smoothing (and differentiation) using a Savitzky-Golay filter.

Detailed Description

Smoothing using Savitzky-Golay filter.

Author
Izadori

References:

  • Savitzky, A.; Golay, M. J. Smoothing And differentiation of Data by Simplified Least Squares Procedures. Anal. Chem. 1964, 36(8), 1627-1639.

Definition in file savitzky_golay.h.

Function Documentation

◆ SavitzkyGolay()

const std::vector< double > sablib::SavitzkyGolay ( const std::vector< double > & y,
const unsigned int n,
const unsigned int polyorder,
const unsigned derive = 0,
const double delta = 1 )

Performs smoothing (and differentiation) using a Savitzky-Golay filter.

Parameters
yThe input data to be filtered.
nThe half-width of the filter window (total window size is 2 * n + 1).
polyorderThe order of the polynomial used for fitting.
deriveThe order of the derivative to compute (0 for smoothing only).
deltaThe spacing of the samples.
Returns
The filtered (smoothed or differentiated) data.
Exceptions
std::invalid_argumentIf the length of y is zero.

Definition at line 72 of file savitzky_golay.cpp.

◆ SavitzkyGolayCoefficients()

const std::vector< double > sablib::SavitzkyGolayCoefficients ( const unsigned int n,
const unsigned int polyorder,
const unsigned derive = 0,
const double delta = 1 )

Calculates the coefficients for a Savitzky-Golay filter.

Parameters
nThe half-width of the filter window (total window size is 2 * n + 1).
polyorderThe order of the polynomial used for fitting.
deriveThe order of the derivative to compute (0 for smoothing only).
deltaThe spacing of the samples.
Returns
The calculated filter coefficients.
Exceptions
std::invalid_argumentOne or more parameters are wrong.

Definition at line 18 of file savitzky_golay.cpp.