sablib
Loading...
Searching...
No Matches
moving_average.cpp File Reference

Smoothing using simple/weighted moving average(implementation). More...

#include "moving_average.h"

Go to the source code of this file.

Functions

const std::vector< double > sablib::MovingAverage (const std::vector< double > &y, const unsigned int n)
 Calculates the simple moving average of the input signal (std::vector<double> version).
const std::vector< double > sablib::WeightedMovingAverage (const std::vector< double > &y, const std::vector< double > &w)
 Calculates the weighted moving average of the input signal (std::vector<double> version).

Detailed Description

Smoothing using simple/weighted moving average(implementation).

Author
Izadori

Definition in file moving_average.cpp.

Function Documentation

◆ MovingAverage()

const std::vector< double > sablib::MovingAverage ( const std::vector< double > & y,
const unsigned int n )

Calculates the simple moving average of the input signal (std::vector<double> version).

Parameters
yThe data to be averaged.
nHalf-width of the moving average window (calculated using 2 * n + 1 points).
Returns
The data after applying the moving average.

Definition at line 14 of file moving_average.cpp.

◆ WeightedMovingAverage()

const std::vector< double > sablib::WeightedMovingAverage ( const std::vector< double > & y,
const std::vector< double > & w )

Calculates the weighted moving average of the input signal (std::vector<double> version).

Parameters
yThe data to be averaged.
wWeights.
Returns
The data after applying the moving average.

Definition at line 29 of file moving_average.cpp.