<jupyter_start><jupyter_text>Moving Average process demo<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
#Define parameters of the moving average process of order 2 (MA(2))

mu= 4.0
theta1=0.5
theta2=0.3
std_eps=1.3

#Define number of time steps 
N = 25

np.random.seed(9)

#Generate tiem series of white noise with mean of 0 and std deviation std_eps
eps_t = np.random.normal(0.0, std_eps, N)

#Plot the time series of white noise
plt.figure(figsize=(14,10))
plt.plot(eps_t, 'o')
plt.show()
#create storage container for MA process
Z_t = np.zeros((N,1))
T= np.arange(0,N,1)

#create the values of the noise process at timesteps t-1 and t-2 to initiate the model

eps_tm1=np.random.normal(0.0, std_eps, 1)
eps_tm2=np.random.normal(0.0, std_eps, 1)

for t in T:
    if t==0:
        Z_t[t] = mu + theta1*eps_tm1 + theta2*eps_tm2
    if t==1:
        Z_t[t] = mu + theta1*eps_t[t-1] + theta2*eps_tm1
    if t>1:
        Z_t[t] = mu + theta1*eps_t[t-1] + theta2*eps_t[t-2]

    
#Plot the time series of white noise
plt.figure(figsize=(14,10))
plt.plot(Z_t, '-')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13082437275985664, 'fraction_numerical': 0.04838709677419355, 'mean_word_length': 4.031531531531532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '644814', 'license': 'MIT', 'n_tokens_mistral': 496, 'n_tokens_neox': 465, 'n_words': 128, 'path': 'Moving_Average_Demo.ipynb', 'repo_name': 'mapatrolia/GEOS_518', 'size': '1116'}