#include <cmath>
#include <cstdint>
#include <vector>
#include "fx_sample.h"
Go to the source code of this file.
|
| struct | Welford_Stats |
| | Maintains running statistics for a stream of values using Welford's online algorithm. More...
|
| |
|
| int64_t | postmod (int64_t a, int64_t m) |
| | Compute a modulo with a non-negative result ("positive modulo"). More...
|
| |
| double | mean_average (const Series &series, int lo, int hi) |
| | Compute the arithmetic mean of a subsequence of samples. More...
|
| |
◆ mean_average()
| double mean_average |
( |
const Series & |
series, |
|
|
int |
lo, |
|
|
int |
hi |
|
) |
| |
Compute the arithmetic mean of a subsequence of samples.
- Parameters
-
| series | The full time series (vector of samples). |
| lo | Inclusive start index within the series. |
| hi | Inclusive end index within the series. |
- Returns
- The mean for the inclusive range [lo, hi], or 0.0 if the range is invalid.
- Note
- Used for initializing Holt-Winters state (level and detrended season).
◆ postmod()
| int64_t postmod |
( |
int64_t |
a, |
|
|
int64_t |
m |
|
) |
| |
Compute a modulo with a non-negative result ("positive modulo").
In C++, the % operator can yield negative remainders if the dividend is negative, which is unsuitable for indexing arrays. This helper ensures the result is always in the range [0, m-1].
- Parameters
-
| a | The integer value (can be negative). |
| m | The modulus (must be positive). |
- Returns
- int64_t The remainder of a divided by m, guaranteed non-negative.
- Note
- Commonly used to wrap seasonal indices in Holt-Winters, ensuring valid access into the seasonal component array.
int64_t postmod(int64_t a, int64_t m)
Compute a modulo with a non-negative result ("positive modulo").
Definition: fx_stats_util.cc:63