Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit 76beced

Browse files
committed
small_fixes
1 parent 31dcb7f commit 76beced

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

source/rst/ar1_processes.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This is called the **state process** and the state space is :math:`\mathbb R`.
5959
To make things even simpler, we will assume that
6060

6161
* 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
6363
* the initial condition :math:`X_0` is independent of :math:`\{ W_t \}`.
6464

6565

@@ -107,7 +107,7 @@ normal random variables are normal.
107107
Given that :math:`X_t` is normally distributed, we will know the full distribution
108108
:math:`\psi_t` if we can pin down its first two moments.
109109

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
111111
of :math:`X_t` respectively.
112112

113113
We can pin down these values from :eq:`ar1_ma` or we can use the following
@@ -118,7 +118,7 @@ recursive expressions:
118118
119119
\mu_{t+1} = a \mu_t + b
120120
\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
122122
123123
These expressions are obtained from :eq:`can_ar1` by taking, respectively, the expectation and variance of both sides of the equality.
124124

@@ -128,11 +128,11 @@ and :math:`W_{t+1}` are independent.
128128
(This follows from our assumptions and :eq:`ar1_ma`.)
129129

130130
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
132132

133133
.. math::
134134
135-
\psi_t = N(\mu_t, \sigma_t^2)
135+
\psi_t = N(\mu_t, v_t)
136136
137137
The following code uses these facts to track the sequence of marginal
138138
distributions :math:`\{ \psi_t \}`.
@@ -143,7 +143,7 @@ The parameters are
143143
144144
a, b, c = 0.9, 0.1, 0.5
145145
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
147147
148148
Here's the sequence of distributions:
149149

@@ -158,8 +158,8 @@ Here's the sequence of distributions:
158158
159159
for t in range(sim_length):
160160
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)),
163163
label=f"$\psi_{t}$",
164164
alpha=0.7)
165165
@@ -180,12 +180,14 @@ This is even clearer if we project forward further into the future:
180180

181181
.. code-block:: python3
182182
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
185185
for t in range(sim_length):
186186
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)
189191
190192
fig, ax = plt.subplots()
191193
plot_density_seq(ax)

0 commit comments

Comments
 (0)