예제 #1
0
def test_ttmle():
    # Test d2.ttmle()
    r_min, r_max = 1.0, 10.0
    r = utils.gprange(r_min, r_max, 100)
    c = np.e * r ** np.pi

    desired = np.pi
    assert_allclose(desired, d2.ttmle(r, c, zero=True)[1])

    desired = np.pi * (c[1:] / (c[1:] - c[0]))
    assert_allclose(desired, d2.ttmle(r, c, zero=False)[1])
예제 #2
0
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]

plt.title('IAAFT surrogates for correlated noise')
plt.xlabel('Distance $r$')
plt.ylabel('Correlation sum $C(r)$')
예제 #3
0
import matplotlib.pyplot as plt
import numpy as np
from nolitsa import surrogates, d2, data

x = data.lorenz(x0=[-13.5, -16.0, 31.0], length=(2**12))[1][:, 0]
x = x[422:3547]

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=[5], tau=5, window=100)[0]

    # Compute the Takens MLE.
    r_mle, mle_surr = d2.ttmle(r, c, zero=False)
    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=[5], tau=5, window=100)[0]

# Compute the Takens MLE.
r_mle, true_mle = d2.ttmle(r, c, zero=False)
i = np.argmax(r_mle > 0.5 * np.std(x))
true_mle = true_mle[i]

plt.title('IAAFT surrogates for Lorenz')
plt.xlabel('Distance $r$')
plt.ylabel('Correlation sum $C(r)$')