Ejemplo n.º 1
0
    returned.

    Parameters
    ----------
    x : array
        1D scalar data set.

    Returns
    -------
    i : array
        Array containing location of all local minima.
    """
    return (np.diff(np.sign(np.diff(x))) > 0).nonzero()[0] + 1


x = data.roessler()[1][:, 0]

# Compute autocorrelation and delayed mutual information.
lag = np.arange(250)
r = delay.acorr(x, maxtau=250)
i = delay.dmi(x, maxtau=250)

# While looking for local minima in the DMI curve, it's useful to do an
# SMA to remove "kinky" minima.
i_delay = localmin(noise.sma(i, hwin=1)) + 1
r_delay = np.argmax(r < 1.0 / np.e)

print(r'Minima of delayed mutual information = %s' % i_delay)
print(r'Autocorrelation time = %d' % r_delay)

plt.figure(1)
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Maximum Lyapunov exponent of the Rössler oscillator.

The "accepted" value is 0.0714, which is quite close to what we get.
"""
from nolitsa import data, lyapunov, utils
import numpy as np
import matplotlib.pyplot as plt

sample = 0.2
x0 = [-3.2916983, -1.42162302, 0.02197593]
x = data.roessler(length=3000, x0=x0, sample=sample)[1][:, 0]

# Choose appropriate Theiler window.
# Since Rössler is an aperiodic oscillator, the average time period is
# a good choice.
f, p = utils.spectrum(x)
window = int(1 / f[np.argmax(p)])

# Time delay.
tau = 7

# Embedding dimension.
dim = [3]

d = lyapunov.mle_embed(x, dim=dim, tau=tau, maxt=200, window=window)[0]
t = np.arange(200)

plt.title(u'Maximum Lyapunov exponent for the Rössler oscillator')
Ejemplo n.º 3
0
data set, we have to "kick" points off the grid a little bit by adding
an insignificant amount of noise.  See Example 6.4 in Kantz & Schreiber
(2004).

But the quality of reconstruction depends on the noise level.  Adding
an insignificant amount of noise does not help at all!  This is
probably one of the rare case where a higher level of additive noise
improves the results.
"""

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

# Generate data.
x = data.roessler(length=5000)[1][:, 0]

# Convert to 8-bit.
x = np.int8(utils.rescale(x, (-127, 127)))

# Add uniform noise of two different noise levels.
y1 = x + (-0.001 + 0.002 * np.random.random(len(x)))
y2 = x + (-0.5 + 1.0 * np.random.random(len(x)))

# AFN algorithm.
dim = np.arange(1, 10 + 2)
F, Fs = dimension.afn(y1, tau=14, dim=dim, window=40)
F1, F2 = F[1:] / F[:-1], Fs[1:] / Fs[:-1]

E, Es = dimension.afn(y2, tau=14, dim=dim, window=40)
E1, E2 = E[1:] / E[:-1], Es[1:] / Es[:-1]
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
"""ADFD algorithm using time series from the Rössler oscillator.

The time delay is taken to be the delay at which the derivative of the
ADFD falls to 40% of its initial value.  The estimated time delay is 5.
Compare with Fig. 6 of Rosenstein et al. (1994).
"""

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

sample = 0.10
x = data.roessler(a=0.20,
                  b=0.40,
                  c=5.7,
                  sample=sample,
                  length=2500,
                  discard=5000)[1][:, 0]

dim = 7
maxtau = 50
tau = np.arange(maxtau)

disp = delay.adfd(x, dim=dim, maxtau=maxtau)
ddisp = np.diff(disp)
forty = np.argmax(ddisp < 0.4 * ddisp[1])

print('Time delay = %d' % forty)

fig, ax1 = plt.subplots()
Ejemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""D2 of the Rössler oscillator.

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

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

x0 = [-3.2916983, -1.42162302, 0.02197593]
x = utils.rescale(data.roessler(length=5000, x0=x0)[1][:, 0])

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

plt.title(u'Local $D_2$ vs $r$ for Rössler oscillator')
plt.xlabel(r'Distance $r$')
plt.ylabel(r'Local $D_2$')

for r, c in d2.c2_embed(x,
                        tau=tau,
                        dim=dim,
                        window=50,
                        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.991 * np.ones(100),
             color='#000000')