Пример #1
0
# end, d = surrogates.mismatch(x, length=1024)

plt.subplot(211)
plt.title(r'Original time series')
plt.ylabel(r'Measurement $x(t)$')

plt.plot(np.arange(3800), x[100:3900], '--')
plt.plot(np.arange(437, 3562), x[537:3662])

plt.subplot(212)
plt.xlabel(r'Time $t$')
plt.ylabel(r'Measurement $x(t)$')
plt.plot(np.arange(3800), x[100:3900], '--')
plt.plot(np.arange(322, 3447), x[422:3547])

y1 = surrogates.iaaft(x[537:3663])[0]
y2 = surrogates.iaaft(x[422:3547])[0]

plt.figure(2)

plt.subplot(211)
plt.title(r'Surrogate time series')
plt.ylabel(r'Measurement $x(t)$')
plt.plot(y1[:500])

plt.subplot(212)
plt.xlabel(r'Time $t$')
plt.ylabel(r'Measurement $x(t)$')
plt.plot(y2[:500])

plt.show()
Пример #2
0
"""

import matplotlib.pyplot as plt
import numpy as np
from nolitsa import surrogates, d2, noise, delay

x = noise.sma(np.random.normal(size=(2 ** 12)), hwin=100)
ends = surrogates.mismatch(x)[0]
x = x[ends[0]:ends[1]]
act = np.argmax(delay.acorr(x) < 1 / np.e)

mle = np.empty(19)

# Compute 19 IAAFT surrogates and compute the correlation sum.
for k in range(19):
    y = surrogates.iaaft(x)[0]
    r, c = d2.c2_embed(y, dim=[7], tau=act, window=act)[0]

    # Compute the Takens MLE.
    r_mle, mle_surr = d2.ttmle(r, c)
    i = np.argmax(r_mle > 0.5 * np.std(y))
    mle[k] = mle_surr[i]

    plt.loglog(r, c, color='#BC8F8F')

r, c = d2.c2_embed(x, dim=[7], tau=act, window=act)[0]

# Compute the Takens MLE.
r_mle, true_mle = d2.ttmle(r, c)
i = np.argmax(r_mle > 0.5 * np.std(x))
true_mle = true_mle[i]
Пример #3
0
surrogates are closer to the true power spectrum (cf. the plot in
"aaft.py").
"""

from scipy.signal import welch
from nolitsa import surrogates

import matplotlib.pyplot as plt
import numpy as np

x = np.loadtxt('../series/br1.dat', usecols=[1], unpack=True)

plt.title(r'Power spectrum of human breath rate (IAAFT surrogates)')
plt.xlabel(r'Frequency $f$')
plt.ylabel(r'Power $P(f)$')

# Compute 19 IAAFT surrogates and plot the spectrum.
for k in range(19):
    y, i, e = surrogates.iaaft(x)
    f, p = welch(y, nperseg=128, detrend='constant',
                 window='boxcar', scaling='spectrum', fs=2.0)

    plt.semilogy(f, p, color='#CA5B7C')

# Calculate true power spectrum.
f0, p0 = welch(x, nperseg=128, detrend='constant',
               window='boxcar', scaling='spectrum', fs=2.0)

plt.semilogy(f0, p0, color='#000000')
plt.show()