@@ -59,7 +59,7 @@ This is called the **state process** and the state space is :math:`\mathbb R`.
59
59
To make things even simpler, we will assume that
60
60
61
61
* the process :math: `\{ W_t \}` is IID and standard normal,
62
- * the initial condition :math: `X_0 ` is drawn from the normal distribution :math: `N(\mu _0 , \sigma _ 0 ^ 2 )` and
62
+ * the initial condition :math: `X_0 ` is drawn from the normal distribution :math: `N(\mu _0 , v_ 0 )` and
63
63
* the initial condition :math: `X_0 ` is independent of :math: `\{ W_t \}`.
64
64
65
65
@@ -107,7 +107,7 @@ normal random variables are normal.
107
107
Given that :math: `X_t` is normally distributed, we will know the full distribution
108
108
:math: `\psi _t` if we can pin down its first two moments.
109
109
110
- Let :math: `\mu _t` and :math: `\sigma _t ` denote the mean and standard deviation
110
+ Let :math: `\mu _t` and :math: `v_t ` denote the mean and variance
111
111
of :math: `X_t` respectively.
112
112
113
113
We can pin down these values from :eq: `ar1_ma ` or we can use the following
@@ -118,7 +118,7 @@ recursive expressions:
118
118
119
119
\mu _{t+1 } = a \mu _t + b
120
120
\quad \text {and} \quad
121
- \sigma ^ 2 _ {t+1 } = a^2 \sigma ^ 2 _t + c^2
121
+ v_ {t+1 } = a^2 v_t + c^2
122
122
123
123
These expressions are obtained from :eq: `can_ar1 ` by taking, respectively, the expectation and variance of both sides of the equality.
124
124
@@ -128,11 +128,11 @@ and :math:`W_{t+1}` are independent.
128
128
(This follows from our assumptions and :eq: `ar1_ma `.)
129
129
130
130
Given the dynamics in :eq: `ar1_ma ` and initial conditions :math: `\mu _0 ,
131
- \sigma _ 0 `, we obtain :math: `\mu _t, \sigma _t ` and hence
131
+ v_ 0 `, we obtain :math: `\mu _t, v_t ` and hence
132
132
133
133
.. math ::
134
134
135
- \psi _t = N(\mu _t, \sigma _t^ 2 )
135
+ \psi _t = N(\mu _t, v_t )
136
136
137
137
The following code uses these facts to track the sequence of marginal
138
138
distributions :math: `\{ \psi _t \}`.
@@ -143,7 +143,7 @@ The parameters are
143
143
144
144
a, b, c = 0.9, 0.1, 0.5
145
145
146
- mu, sigma = -3.0, 0.4 # initial conditions mu_0, sigma_0
146
+ mu, v = -3.0, 0.6 # initial conditions mu_0, v_0
147
147
148
148
Here's the sequence of distributions:
149
149
@@ -158,8 +158,8 @@ Here's the sequence of distributions:
158
158
159
159
for t in range(sim_length):
160
160
mu = a * mu + b
161
- sigma = np.sqrt( a**2 * sigma**2 + c**2)
162
- ax.plot(grid, norm.pdf(grid, loc=mu, scale=sigma ),
161
+ v = a**2 * v + c**2
162
+ ax.plot(grid, norm.pdf(grid, loc=mu, scale=np.sqrt(v) ),
163
163
label=f"$\psi_{t}$",
164
164
alpha=0.7)
165
165
@@ -180,12 +180,14 @@ This is even clearer if we project forward further into the future:
180
180
181
181
.. code-block :: python3
182
182
183
- def plot_density_seq(ax, mu_0=-3.0, sigma_0 =0.4 , sim_length=60):
184
- mu, sigma = mu_0, sigma_0
183
+ def plot_density_seq(ax, mu_0=-3.0, v_0 =0.6 , sim_length=60):
184
+ mu, v = mu_0, v_0
185
185
for t in range(sim_length):
186
186
mu = a * mu + b
187
- sigma = np.sqrt(a**2 * sigma**2 + c**2)
188
- ax.plot(grid, norm.pdf(grid, loc=mu, scale=sigma), alpha=0.5)
187
+ v = a**2 * v + c**2
188
+ ax.plot(grid,
189
+ norm.pdf(grid, loc=mu, scale=np.sqrt(v)),
190
+ alpha=0.5)
189
191
190
192
fig, ax = plt.subplots()
191
193
plot_density_seq(ax)
0 commit comments