C++ Template of Exponential Smoothing


This is a simple C++ template library of Exponential Smoothing implemented by Shuo Jin.

In current version, single and double exponential smoothing methods are implemented with consistent and simple functions.

Date Structure:

All smoothing constants in the above data structures are set to 0.5 by default. Users can change their value by calling the corresponding functions. Optimization based determination of optimal smoothing constants is not included at present. The current implementation is mainly used for forecasting, which is very easy to use with the only core function push_to_pop. In order to further filter data noise, a vacillation tolerance (0 by default) can be set. Only when the difference (L2 norm) of current smoothed vector and the last one is bigger than the specified tolerance, the current one will be returned. Otherwise, the last smoothed vector will be returned.


#include <exponential_smoothing.h>

#define DIMENSION 3

int main(int argc, char* argv[])
    // declare an object
    double_exponential_smoothing<double, DIMENSION> dbexpsmth; // or single_exponential_smoothing

    // change the value accordingly


        // declare a vector
        es_vec<double, DIMENSION> curr_query;

        // value assignment
        for (size_t i = 0; i < DIMENSION; ++i) curr_query[i] = ...;

        // smoothing
        es_vec<double, DIMENSION> smth_result = dbexpsmth.push_to_pop(curr_query);


The code is available here.


  1. Wikipedia - Exponential Smoothing
  2. A online handbook - Exponential Smoothing