1 /*****************************************************************************
2 * rrd_hw_math.h Math functions for Holt-Winters computations
3 *****************************************************************************/
6 #include "rrd_format.h"
8 /* since /usr/include/bits/mathcalls.h:265 defines gamma already */
11 /*****************************************************************************
12 * Functions for additive Holt-Winters
13 *****************************************************************************/
15 rrd_value_t hw_additive_calculate_prediction(
16 rrd_value_t intercept,
19 rrd_value_t seasonal_coef);
21 rrd_value_t hw_additive_calculate_intercept(
24 rrd_value_t seasonal_coef,
27 rrd_value_t hw_additive_calculate_seasonality(
30 rrd_value_t intercept,
31 rrd_value_t seasonal_coef);
33 rrd_value_t hw_additive_init_seasonality(
34 rrd_value_t seasonal_coef,
35 rrd_value_t intercept);
37 /*****************************************************************************
38 * Functions for multiplicative Holt-Winters
39 *****************************************************************************/
41 rrd_value_t hw_multiplicative_calculate_prediction(
42 rrd_value_t intercept,
45 rrd_value_t seasonal_coef);
47 rrd_value_t hw_multiplicative_calculate_intercept(
50 rrd_value_t seasonal_coef,
53 rrd_value_t hw_multiplicative_calculate_seasonality(
56 rrd_value_t intercept,
57 rrd_value_t seasonal_coef);
59 rrd_value_t hw_multiplicative_init_seasonality(
60 rrd_value_t seasonal_coef,
61 rrd_value_t intercept);
63 /*****************************************************************************
64 * Math functions common to additive and multiplicative Holt-Winters
65 *****************************************************************************/
67 rrd_value_t hw_calculate_slope(
71 rrd_value_t hw_calculate_seasonal_deviation(
73 rrd_value_t prediction,
77 rrd_value_t hw_init_seasonal_deviation(
78 rrd_value_t prediction,
79 rrd_value_t observed);
82 /* Function container */
84 typedef struct hw_functions_t {
87 rrd_value_t intercept,
90 rrd_value_t seasonal_coef);
96 rrd_value_t seasonal_coef,
107 rrd_value_t observed,
108 rrd_value_t intercept,
109 rrd_value_t seasonal_coef);
113 rrd_value_t seasonal_coef,
114 rrd_value_t intercept);
117 *seasonal_deviation) (
119 rrd_value_t prediction,
120 rrd_value_t observed,
124 *init_seasonal_deviation) (
125 rrd_value_t prediction,
126 rrd_value_t observed);
128 rrd_value_t identity;