# naginterfaces.library.tsa.inhom_​iema¶

naginterfaces.library.tsa.inhom_iema(iema, t, tau, inter, sinit=None, pn=0, comm=None)[source]

inhom_iema calculates the iterated exponential moving average for an inhomogeneous time series.

For full information please refer to the NAG Library document for g13me

https://www.nag.com/numeric/nl/nagdoc_27.3/flhtml/g13/g13mef.html

Parameters
iemafloat, array-like, shape

, the current block of observations, for , where is the number of observations processed so far, i.e., the value supplied in on entry.

tfloat, array-like, shape

, the times for the current block of observations, for , where is the number of observations processed so far, i.e., the value supplied in on entry.

If , = 31 will be returned, but inhom_iema will continue as if was strictly increasing by using the absolute value.

taufloat

, the parameter controlling the rate of decay, which must be sufficiently large that , can be calculated without overflowing, for all .

interint, array-like, shape

The type of interpolation used with indicating the interpolation method to use when calculating and the interpolation method to use when calculating , .

Three types of interpolation are possible:

Previous point, with .

Linear, with .

Next point, .

Zumbach and Müller (2001) recommend that linear interpolation is used in second and subsequent iterations, i.e., , irrespective of the interpolation method used at the first iteration, i.e., the value of .

sinitNone or float, array-like, shape , optional

If , the values used to start the iterative process, with

,

,

, for .

If , is not referenced.

pnint, optional

, the number of observations processed so far. On the first call to inhom_iema, or when starting to summarise a new dataset, must be set to . On subsequent calls it must be the same value as returned by the last call to inhom_iema.

commNone or dict, communication object, optional, modified in place

Communication structure.

On initial entry: need not be set.

Returns
iemafloat, ndarray, shape

The iterated EMA, with .

pnint

, the updated number of observations processed so far.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: if linear interpolation is being used.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On entry at previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On entry at previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, and .

On entry at previous call, , .

Constraint: if , must be unchanged since the previous call.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On exit from previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

[‘rcomm’] has been corrupted between calls.

(errno )

On entry, , and .

Constraint: if , or .

(errno )

On entry, , and .

Constraint: if , .

Warns
NagAlgorithmicWarning
(errno )

On entry, , and .

Constraint: should be strictly increasing.

(errno )

Truncation occurred to avoid overflow, check for extreme values in , or for .

Notes

inhom_iema calculates the iterated exponential moving average for an inhomogeneous time series. The time series is represented by two vectors of length ; a vector of times, ; and a vector of values, . Each element of the time series is, therefore, composed of the pair of scalar values , for . Time can be measured in any arbitrary units, as long as all elements of use the same units.

The exponential moving average (EMA), with parameter , is an average operator, with the exponentially decaying kernel given by

The exponential form of this kernel gives rise to the following iterative formula for the EMA operator (see Zumbach and Müller (2001)):

where

The value of depends on the method of interpolation chosen. inhom_iema gives the option of three interpolation methods:

 Previous point: ν=1; Linear: ν=(1−μ)/α; Next point: ν=μ.

The -iterated exponential moving average, , , is defined using the recursive formula:

with

For large datasets or where all the data is not available at the same time, and can be split into arbitrary sized blocks and inhom_iema called multiple times.

References

Dacorogna, M M, Gencay, R, Müller, U, Olsen, R B and Pictet, O V, 2001, An Introduction to High-frequency Finance, Academic Press

Zumbach, G O and Müller, U A, 2001, Operators on inhomogeneous time series, International Journal of Theoretical and Applied Finance (4(1)), 147–178