ALSSM Evaluation [ex102.0]

Evaluates the output of a given ALSSM for one or multiple initial states and time steps (time indeces).

../../_images/sphx_glr_example-ex102.0-alssm-evaluation_001.png

Out:

--DUMP--
 └-Alssm : polynomial, A: (4, 4), C: (1, 4), label: 3nd order

--PRINT--
 A =
[[1 1 1 1]
 [0 1 2 3]
 [0 0 1 3]
 [0 0 0 1]]
C =
[[1 0 0 0]]

import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import find_peaks

import lmlib as lm


# ------------ Evaluate ALSSM -------------
js = np.arange(-20, 20) # ALSSM evaluation range

js = range(-20, 20) # ALSSM evaluation range

alssm = lm.AlssmPoly(poly_degree=1,label='1th order')
x0s1 = [[-1, 2]] # ALSSM initial state vector(s)
ys1 = alssm.eval(x0s1, js)

alssm = lm.AlssmPoly(poly_degree=2,label='2nd order')
x0s2 = [[-1, 2, .1]] # ALSSM initial state vector(s)
ys2 = alssm.eval(x0s2, js)

alssm = lm.AlssmPoly(poly_degree=3,label='3nd order')
x0s3 = [[-1, 2, .1, -.01]] # ALSSM initial state vector(s)
ys3 = alssm.eval(x0s3, js)


# Printing Model to Console
print("--DUMP--\n", alssm.dump_tree())
print("--PRINT--\n", alssm)

# ------------ Plot ALSSM -------------
fig, ax = plt.subplots(1, 1, figsize=(4, 3))
ax.set_title('Polynomial ALSSM Evaluation $s_i(x_0)$')
ax.plot(js, ys1[0, :, :], '.-', lw=.5, c='tab:red', label='$x_0 = ' + str(x0s1) + '^\mathrm{T}$')
ax.plot(js, ys2[0, :, :], '.-', lw=.5, c='tab:blue', label='$x_0 = ' + str(x0s2) + '^\mathrm{T}$')
ax.plot(js, ys3[0, :, :], '.-', lw=.5, c='tab:green', label='$x_0 = ' + str(x0s2) + '^\mathrm{T}$')
ax.set(xlabel='Evaluation index $i$')

plt.legend()
plt.show()

Total running time of the script: ( 0 minutes 0.512 seconds)

Gallery generated by Sphinx-Gallery