This site is best viewed in a browser that conforms to web standards.



BOOL ivorix_lma (
vector<double>& ivec, // input vector
vector<double>& ovec, // output vector
unsigned long span) // time period or span of embedding
{
ULONG x = 0;
ULONG y = 0;
ULONG p = 0;
ULONG e = ivec.size();
double sum = 0;
double div = 0;
if ( span == 0 || span >= e )
return false;
ovec.resize(ivec.size());
ovec[0] = ivec[0];
for ( x = 1; x < e; x++ )
{
sum = 0;
p = min(x, span);
if ( p <= span )
{
div = 0;
for ( y = 1; y <= p; y++ )
div += y;
}
for ( y = 0; y < p; y++ )
sum += ivec[x-y] * (p - y);
ovec[x] = sum / div;
}
return true;
}