![]() |
sablib
|
The C interface of sablib smoothing functions.(implementation). More...
#include <algorithm>#include <vector>#include "smoothing.h"#include "../smoothing/moving_average.h"#include "../smoothing/moving_median.h"#include "../smoothing/pspline.h"#include "../smoothing/savitzky_golay.h"#include "../smoothing/whittaker.h"Go to the source code of this file.
Functions | |
| const SABLIB_DATA_PTR | Sablib_MovingAverage (const SABLIB_DATA_PTR y, const unsigned int n) |
| Calculates the simple moving average of the input signal. | |
| const SABLIB_DATA_PTR | Sablib_WeightedMovingAverage (const SABLIB_DATA_PTR y, const SABLIB_DATA_PTR w) |
| Calculates the weighted moving average of the input signal. | |
| const SABLIB_DATA_PTR | Sablib_GaussianKernel (const unsigned int n, const double sigma) |
| Generates a Gaussian kernel. | |
| const SABLIB_DATA_PTR | Sablib_GaussianFilter (const SABLIB_DATA_PTR y, const unsigned int n, const double sigma) |
| Performs Gaussian smoothing on the input signal. | |
| const SABLIB_DATA_PTR | Sablib_MovingMedian (const SABLIB_DATA_PTR y, const unsigned int n) |
| Performs moving median smoothing. | |
| const SABLIB_DATA_PTR | Sablib_PSpline (const SABLIB_DATA_PTR y, const unsigned int knots_num, const unsigned int degree, const unsigned int s, const double lambda) |
| Smoothes the input data using P-Splines (Penalized B-Splines). | |
| const SABLIB_DATA_PTR | Sablib_SavitzkyGolayCoefficients (const unsigned int n, const unsigned int polyorder, const unsigned derive, const double delta) |
| Calculates the coefficients for a Savitzky-Golay filter. | |
| const SABLIB_DATA_PTR | Sablib_SavitzkyGolay (const SABLIB_DATA_PTR y, const unsigned int n, const unsigned int polyorder, const unsigned derive, const double delta) |
| Performs smoothing (and differentiation) using a Savitzky-Golay filter. | |
| const SABLIB_DATA_PTR | Sablib_WeightedWhittaker (const SABLIB_DATA_PTR y, const SABLIB_DATA_PTR w, const double lambda, const unsigned int s) |
| Performs Whittaker smoothing (with weights). | |
| const SABLIB_DATA_PTR | Sablib_Whittaker (const SABLIB_DATA_PTR y, const double lambda, const unsigned int s) |
| Performs Whittaker smoothing (without weights). | |
The C interface of sablib smoothing functions.(implementation).
Definition in file smoothing.cpp.
| const SABLIB_DATA_PTR Sablib_GaussianFilter | ( | const SABLIB_DATA_PTR | y, |
| const unsigned int | n, | ||
| const double | sigma ) |
Performs Gaussian smoothing on the input signal.
This is a convenience function that generates a Gaussian kernel and then applies it using Sablib_WeightedMovingAverage.
| y | The data to be smoothed. |
| n | Half-width of the Gaussian window (total size is 2 * n + 1). |
| sigma | The standard deviation of the Gaussian distribution. |
Definition at line 67 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_GaussianKernel | ( | const unsigned int | n, |
| const double | sigma ) |
Generates a Gaussian kernel.
| n | Half-width of the Gaussian window (total size is 2 * n + 1). |
| sigma | The standard deviation of the Gaussian distribution. |
Definition at line 54 of file smoothing.cpp.
References AllocSablibData(), and _stSablibData::data.
| const SABLIB_DATA_PTR Sablib_MovingAverage | ( | const SABLIB_DATA_PTR | y, |
| const unsigned int | n ) |
Calculates the simple moving average of the input signal.
| y | The data to be averaged. |
| n | Half-width of the moving average window (calculated using 2 * n + 1 points). |
Definition at line 21 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_MovingMedian | ( | const SABLIB_DATA_PTR | y, |
| const unsigned int | n ) |
Performs moving median smoothing.
| y | The input data vector (signal to be smoothed). |
| n | Half-width of the moving median window (calculated using 2 * n + 1 points). |
Definition at line 83 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_PSpline | ( | const SABLIB_DATA_PTR | y, |
| const unsigned int | knots_num, | ||
| const unsigned int | degree, | ||
| const unsigned int | s, | ||
| const double | lambda ) |
Smoothes the input data using P-Splines (Penalized B-Splines).
This function applies a B-Spline basis with a difference penalty on the coefficients to achieve smoothing of the input data.
| y | The input data points to be smoothed. |
| knots_num | The number of internal knots for the B-Spline basis. |
| degree | The degree of the B-Spline basis (default is 3, cubic spline). |
| s | The order of the difference penalty (default is 2). |
| lambda | The smoothing parameter (default is 1.0). Larger values result in smoother curves. |
Definition at line 99 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_SavitzkyGolay | ( | const SABLIB_DATA_PTR | y, |
| const unsigned int | n, | ||
| const unsigned int | polyorder, | ||
| const unsigned | derive, | ||
| const double | delta ) |
Performs smoothing (and differentiation) using a Savitzky-Golay filter.
| y | The input data to be filtered. |
| n | The half-width of the filter window (total window size is 2 * n + 1). |
| polyorder | The order of the polynomial used for fitting. |
| derive | The order of the derivative to compute (0 for smoothing only). |
| delta | The spacing of the samples. |
Definition at line 133 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_SavitzkyGolayCoefficients | ( | const unsigned int | n, |
| const unsigned int | polyorder, | ||
| const unsigned | derive, | ||
| const double | delta ) |
Calculates the coefficients for a Savitzky-Golay filter.
| n | The half-width of the filter window (total window size is 2 * n + 1). |
| polyorder | The order of the polynomial used for fitting. |
| derive | The order of the derivative to compute (0 for smoothing only). |
| delta | The spacing of the samples. |
Definition at line 118 of file smoothing.cpp.
References AllocSablibData(), and _stSablibData::data.
| const SABLIB_DATA_PTR Sablib_WeightedMovingAverage | ( | const SABLIB_DATA_PTR | y, |
| const SABLIB_DATA_PTR | w ) |
Calculates the weighted moving average of the input signal.
| y | The data to be averaged. |
| w | Weights. |
Definition at line 37 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_WeightedWhittaker | ( | const SABLIB_DATA_PTR | y, |
| const SABLIB_DATA_PTR | w, | ||
| const double | lambda, | ||
| const unsigned int | s ) |
Performs Whittaker smoothing (with weights).
| y | The input data to be smoothed. |
| w | Weights for each data point. |
| lambda | Smoothing parameter (larger values lead to more smoothing, but may flatten peaks). |
| s | The order of the difference (usually s = 1, 2, or 3). |
Definition at line 152 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.
| const SABLIB_DATA_PTR Sablib_Whittaker | ( | const SABLIB_DATA_PTR | y, |
| const double | lambda, | ||
| const unsigned int | s ) |
Performs Whittaker smoothing (without weights).
| y | The input data to be smoothed. |
| lambda | Smoothing parameter (larger values lead to more smoothing, but may flatten peaks). |
| s | The order of the difference (usually s = 1, 2, or 3). |
Definition at line 172 of file smoothing.cpp.
References AllocSablibData(), _stSablibData::data, and _stSablibData::size.