The exponential moving average is probably the most commonly used moving average
in financial applications. The 'C' version is shown below.
Test case is also shown at the bottom.
Anyone up to converting this to a IPP optimized function. Shouldn't
be to hard, it just consists of addition/subtraction/division. I might
be able to pay you for your time. I also have other 'c' functions
that could be rewritten if someone gets motiviated. Test case
with performance before and after would be useful.
This would be a good function to add to IPP, its used very commonly.
For more on EMA:
//(Close - EMA(previous day)) x multiplier + EMA(previous day)
void ema_32f(const float* src, float* out, int size, int factor)
{
IppStatus status;
float k;
int n;
n = size - factor;
ippsMean_32f(src + n, factor, &out, ippAlgHintFast);
--n;
k = 2.0f / (factor + 1.0f);
for(int m = n; m >= 0; --m)
out = ((src - out[m + 1]) * k) + out[m + 1];
}
float data[] = {22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43, 22.24, 22.29, 22.15, 22.39,22.38, 22.61, 23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82, 23.87, 23.65, 23.19,23.10, 23.33, 22.68, 23.10, 22.40, 22.17, 22.17, 22.17, 22.17, 22.17};
float result[20];
ema_32f(data, result, 30, 10);
assert(std::abs(22.296 - result[0]) <= 0.01)
assert(std::abs(23.222 - result[19]) <= 0.01)