コード例 #1
0
ファイル: ikeda.py プロジェクト: linodol/TCC-do-Marco
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""AFN for time series from the Ikeda map.

E1 saturates near an embedding dimension of 4.  E2 != 1 at many values
of d.  Thus, this series is definitely deterministic.  Compare with
Fig. 2 of Cao (1997).
"""

from nolitsa import data, dimension
import matplotlib.pyplot as plt
import numpy as np

# Generate data.
x = data.ikeda()[:, 0]

# AFN algorithm.
dim = np.arange(1, 10 + 2)
E, Es = dimension.afn(x, tau=1, dim=dim, window=5)
E1, E2 = E[1:] / E[:-1], Es[1:] / Es[:-1]

plt.title(r'AFN for time series from the Ikeda map')
plt.xlabel(r'Embedding dimension $d$')
plt.ylabel(r'$E_1(d)$ and $E_2(d)$')
plt.plot(dim[:-1], E1, 'bo-', label=r'$E_1(d)$')
plt.plot(dim[:-1], E2, 'go-', label=r'$E_2(d)$')
plt.legend()

plt.show()
コード例 #2
0
ファイル: ikeda.py プロジェクト: yanyan-cas/nolitsa
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""D2 of the Ikeda map.

The estimates here match the "accepted" value of 1.690 quite closely.
"""

import numpy as np
import matplotlib.pyplot as plt
from nolitsa import d2, data, utils

x = utils.rescale(data.ikeda(length=5000)[:, 0])

dim = np.arange(1, 10 + 1)
tau = 1

plt.title('Local $D_2$ vs $r$ for Ikeda map')
plt.xlabel(r'Distance $r$')
plt.ylabel(r'Local $D_2$')

for r, c in d2.c2_embed(x,
                        tau=tau,
                        dim=dim,
                        window=2,
                        r=utils.gprange(0.001, 1.0, 100)):
    plt.semilogx(r[3:-3], d2.d2(r, c), color='#4682B4')

plt.semilogx(utils.gprange(0.001, 1.0, 100),
             1.690 * np.ones(100),
             color='#000000')
plt.show()
コード例 #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""FNN for time series from the Ikeda map.

This is a purely deterministic time series, yet we see the second test
reporting FNNs at large embedding dimensions.  The whole problem is that
the fraction of FNN strongly depends on the threshold parameters
used (apart from the metric).
"""

from nolitsa import data, dimension
import matplotlib.pyplot as plt
import numpy as np

# Generate data.
x = data.ikeda(length=5000)[:, 0]
dim = np.arange(1, 15 + 1)

f1 = dimension.fnn(x, tau=1, dim=dim, window=0, metric='chebyshev')[2]
f2 = dimension.fnn(x, tau=1, dim=dim, window=0, metric='euclidean')[2]
f3 = dimension.fnn(x, tau=1, dim=dim, window=0, metric='cityblock')[2]

plt.title(r'FNN for the Ikeda map')
plt.xlabel(r'Embedding dimension $d$')
plt.ylabel(r'FNN (%)')
plt.plot(dim, 100 * f1, 'bo-', label=r'Chebyshev')
plt.plot(dim, 100 * f2, 'g^-', label=r'Euclidean')
plt.plot(dim, 100 * f3, 'rs-', label=r'Cityblock')
plt.legend()

plt.show()