import numpy as np import matplotlib.pyplot as plt from lss import LSS phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.2 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] ar = LSS(A, C, G, mu_0=np.ones(4)) x, y = ar.simulate(ts_length=200) fig, ax = plt.subplots(figsize=(8, 4.6)) y = y.flatten() ax.plot(y, 'b-', lw=2, alpha=0.7) ax.grid() ax.set_xlabel('time') ax.set_ylabel(r'$y_t$', fontsize=16) plt.show()
phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] T0 = 10 T1 = 50 T2 = 75 T4 = 100 ar = LSS(A, C, G, mu_0=np.ones(4)) ymin, ymax = -0.8, 1.25 fig, ax = plt.subplots(figsize=(8, 5)) ax.grid(alpha=0.4) ax.set_ylim(ymin, ymax) ax.set_ylabel(r'$y_t$', fontsize=16) ax.vlines((T0, T1, T2), -1.5, 1.5) ax.set_xticks((T0, T1, T2)) ax.set_xticklabels((r"$T$", r"$T'$", r"$T''$"), fontsize=14) sample = [] for i in range(80): rcolor = random.choice(('c', 'g', 'b'))
import numpy as np import matplotlib.pyplot as plt from lss import LSS phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.2 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [[sigma], [0], [0], [0]] G = [1, 0, 0, 0] ar = LSS(A, C, G, mu_0=np.ones(4)) x, y = ar.simulate(ts_length=200) fig, ax = plt.subplots(figsize=(8, 4.6)) y = y.flatten() ax.plot(y, 'b-', lw=2, alpha=0.7) ax.grid() ax.set_xlabel('time') ax.set_ylabel(r'$y_t$', fontsize=16) plt.show()
import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm from lss import LSS import random phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [[sigma], [0], [0], [0]] G = [1, 0, 0, 0] I = 20 T = 50 ar = LSS(A, C, G, mu_0=np.ones(4)) ymin, ymax = -0.5, 1.15 fig, ax = plt.subplots() ax.set_ylim(ymin, ymax) ax.set_xlabel(r'time', fontsize=16) ax.set_ylabel(r'$y_t$', fontsize=16) ensemble_mean = np.zeros(T) for i in range(I): x, y = ar.simulate(ts_length=T) y = y.flatten() ax.plot(y, 'c-', lw=0.8, alpha=0.5) ensemble_mean = ensemble_mean + y
phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] T0 = 10 T1 = 50 T2 = 75 T4 = 100 ar = LSS(A, C, G, mu_0=np.ones(4)) ymin, ymax = -0.8, 1.0 fig, ax = plt.subplots(figsize=(8, 5)) ax.grid(alpha=0.4) ax.set_ylim(ymin, ymax) ax.set_ylabel(r'$y_t$', fontsize=16) ax.vlines((T0, T1, T2), -1.5, 1.5) ax.set_xticks((T0, T1, T2)) ax.set_xticklabels((r"$T$", r"$T'$", r"$T''$"), fontsize=14) mu_x, mu_y, Sigma_x, Sigma_y = ar.stationary_distributions() ar.mu_0 = mu_x ar.Sigma_0 = Sigma_x
from scipy.stats import norm from lss import LSS import random phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] T = 30 ar = LSS(A, C, G) ymin, ymax = -0.8, 1.25 fig, ax = plt.subplots(figsize=(8,4)) ax.set_xlim(ymin, ymax) ax.set_xlabel(r'$y_t$', fontsize=16) x, y = ar.replicate(T=T, num_reps=500000, mu_0=np.ones(4)) mu_x, mu_y, Sigma_x, Sigma_y = ar.moments(T=T, mu_0=np.ones(4)) f_y = norm(loc=float(mu_y), scale=float(np.sqrt(Sigma_y))) y = y.flatten() ax.hist(y, bins=50, normed=True, alpha=0.4)
from lss import LSS import random phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] I = 20 T = 50 ar = LSS(A, C, G, mu_0=np.ones(4)) ymin, ymax = -0.5, 1.15 fig, ax = plt.subplots() ax.set_ylim(ymin, ymax) ax.set_xlabel(r'time', fontsize=16) ax.set_ylabel(r'$y_t$', fontsize=16) ensemble_mean = np.zeros(T) for i in range(I): x, y = ar.simulate(ts_length=T) y = y.flatten() ax.plot(y, 'c-', lw=0.8, alpha=0.5) ensemble_mean = ensemble_mean + y
from lss import LSS import random phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] T0 = 10 T1 = 50 T2 = 75 T4 = 100 ar = LSS(A, C, G, mu_0=np.ones(4)) ymin, ymax = -0.8, 1.0 fig, ax = plt.subplots(figsize=(8, 5)) ax.grid(alpha=0.4) ax.set_ylim(ymin, ymax) ax.set_ylabel(r'$y_t$', fontsize=16) ax.vlines((T0, T1, T2), -1.5, 1.5) ax.set_xticks((T0, T1, T2)) ax.set_xticklabels((r"$T$", r"$T'$", r"$T''$"), fontsize=14) mu_x, mu_y, Sigma_x, Sigma_y = ar.stationary_distributions() ar.mu_0 = mu_x ar.Sigma_0 = Sigma_x
import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm from lss import LSS import random phi_1, phi_2, phi_3, phi_4 = 0.5, -0.2, 0, 0.5 sigma = 0.1 A = [[phi_1, phi_2, phi_3, phi_4], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]] C = [sigma, 0, 0, 0] G = [1, 0, 0, 0] T = 30 ar = LSS(A, C, G) ymin, ymax = -0.8, 1.25 fig, ax = plt.subplots(figsize=(8, 4)) ax.set_xlim(ymin, ymax) ax.set_xlabel(r"$y_t$", fontsize=16) x, y = ar.replicate(T=T, num_reps=500000, mu_0=np.ones(4)) mu_x, mu_y, Sigma_x, Sigma_y = ar.moments(T=T, mu_0=np.ones(4)) f_y = norm(loc=float(mu_y), scale=float(np.sqrt(Sigma_y))) y = y.flatten() ax.hist(y, bins=50, normed=True, alpha=0.4) ygrid = np.linspace(ymin, ymax, 150)
import numpy as np import matplotlib.pyplot as plt from lss import LSS phi_0, phi_1, phi_2 = 1.1, 0.8, -0.8 A = [[1, 0, 0], [phi_0, phi_1, phi_2], [0, 1, 0]] C = np.zeros((3, 1)) G = [0, 1, 0] ar = LSS(A, C, G, mu_0=np.ones(3)) x, y = ar.simulate(ts_length=50) fig, ax = plt.subplots(figsize=(8, 4.6)) y = y.flatten() ax.plot(y, 'b-', lw=2, alpha=0.7) ax.grid() ax.set_xlabel('time') ax.set_ylabel(r'$y_t$', fontsize=16) plt.show()