Source code for naginterfaces.library.examples.tsa.inhom_iema_ex

#!/usr/bin/env python3
"``naginterface.library.tsa.inhom_iema`` Python Example."

# NAG Copyright 2017-2019.

# pylint: disable=invalid-name

from naginterfaces.library import tsa

[docs]def main(): """ Example for :func:`naginterfaces.library.tsa.inhom_iema`. Iterated exponential moving average for a univariate inhomogeneous time series. >>> main() naginterfaces.library.tsa.inhom_iema Python Example Results. IEMA for an inhomogeneous time series. Time IEMA ______________ 7.500 0.531 8.200 0.544 18.100 0.754 22.800 0.406 25.800 0.232 26.800 0.217 31.100 0.357 38.400 0.630 45.900 0.263 48.200 0.241 48.900 0.279 57.900 0.713 58.500 0.717 63.900 0.385 65.200 0.346 66.600 0.330 67.400 0.315 69.300 0.409 69.900 0.459 73.000 0.377 75.600 0.411 77.000 0.536 84.700 0.632 86.800 0.538 88.000 0.444 88.500 0.401 91.000 0.331 93.000 0.495 93.700 0.585 94.000 0.612 """ print('naginterfaces.library.tsa.inhom_iema Python Example Results.') print('IEMA for an inhomogeneous time series.') # The observations and times: iema = [ 0.6, 0.6, 0.8, 0.1, 0.2, 0.2, 0.5, 0.7, 0.1, 0.4, 0.7, 0.8, 0.3, 0.2, 0.5, 0.2, 0.3, 0.8, 0.6, 0.1, 0.7, 0.9, 0.6, 0.3, 0.1, 0.1, 0.4, 1.0, 1.0, 0.1, ] t = [ 7.5, 8.2, 18.1, 22.8, 25.8, 26.8, 31.1, 38.4, 45.9, 48.2, 48.9, 57.9, 58.5, 63.9, 65.2, 66.6, 67.4, 69.3, 69.9, 73.0, 75.6, 77.0, 84.7, 86.8, 88.0, 88.5, 91.0, 93.0, 93.7, 94.0, ] # The decay parameter: tau = 2. # The starting parameters: sinit = [5., 0.5, 0.5, 0.5] # The interpolation type: inter = [3, 2] iema = tsa.inhom_iema(iema, t, tau, inter, sinit=sinit).iema header_str = " Time IEMA" print(header_str) print('_'*(len(header_str)+1)) for i, t_i in enumerate(t): print('{:6.3f} {:6.3f}'.format(t_i, iema[i]))
if __name__ == '__main__': import doctest import sys sys.exit( doctest.testmod( None, verbose=True, report=False, optionflags=doctest.REPORT_NDIFF, ).failed )