Skip to content

Commit 1578016

Browse files
committed
Use different variable names for while and for loop.
1 parent 817b644 commit 1578016

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lectures/mccall_model.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ economists to inject randomness into their models.)
9191

9292
In this lecture, we adopt the following simple environment:
9393

94-
* $\{s_t\}$ is IID, with $q(s)$ being the probability of observing state $s$ in $\mathbb{S}$ at each point in time,
94+
* $\{s_t\}$ is IID, with $q(s)$ being the probability of observing state $s$ in $\mathbb{S}$ at each point in time,
9595
* the agent observes $s_t$ at the start of $t$ and hence knows
9696
$w_t = w(s_t)$,
9797
* the set $\mathbb S$ is finite.
@@ -120,7 +120,7 @@ The variable $y_t$ is income, equal to
120120
* unemployment compensation $c$ when unemployed
121121

122122
The worker knows that $\{s_t\}$ is IID with common
123-
distribution $q$ and uses knowledge when he or she computes mathematical expectations of various random variables that are functions of
123+
distribution $q$ and uses knowledge when he or she computes mathematical expectations of various random variables that are functions of
124124
$s_t$.
125125

126126
### A Trade-Off
@@ -134,7 +134,7 @@ To decide optimally in the face of this trade-off, we use dynamic programming.
134134

135135
Dynamic programming can be thought of as a two-step procedure that
136136

137-
1. first assigns values to "states"
137+
1. first assigns values to "states"
138138
1. then deduces optimal actions given those values
139139

140140
We'll go through these steps in turn.
@@ -160,16 +160,16 @@ Let $v^*(s)$ be the optimal value of the problem when $s \in \mathbb{S}$ for a
160160

161161

162162

163-
Thus, the function $v^*(s)$ is the maximum value of objective
163+
Thus, the function $v^*(s)$ is the maximum value of objective
164164
{eq}`objective` for a previously unemployed worker who has offer $w(s)$ in hand and has yet to choose whether to accept it.
165165

166166
Notice that $v^*(s)$ is part of the **solution** of the problem, so it isn't obvious that it is a good idea to start working on the problem by focusing on $v^*(s)$.
167167

168168
There is a chicken and egg problem: we don't know how to compute $v^*(s)$ because we don't yet know
169169
what decisions are optimal and what aren't!
170170

171-
But it turns out to be a really good idea by asking what properties the optimal value function $v^*(s)$ must have in order it
172-
to qualify as an optimal value function.
171+
But it turns out to be a really good idea by asking what properties the optimal value function $v^*(s)$ must have in order it
172+
to qualify as an optimal value function.
173173

174174
Think of $v^*$ as a function that assigns to each possible state
175175
$s$ the maximal expected discounted income stream that can be obtained with that offer in
@@ -192,7 +192,7 @@ for every possible $s$ in $\mathbb S$.
192192
Notice how the function $v^*(s)$ appears on both the right and left sides of equation {eq}`odu_pv` -- that is why it is called
193193
a **functional equation**, i.e., an equation that restricts a **function**.
194194

195-
This important equation is a version of a **Bellman equation**, an equation that is
195+
This important equation is a version of a **Bellman equation**, an equation that is
196196
ubiquitous in economic dynamics and other fields involving planning over time.
197197

198198
The intuition behind it is as follows:
@@ -218,7 +218,7 @@ Once we have this function in hand we can figure out how behave optimally (i.e.
218218

219219
All we have to do is select the maximal choice on the r.h.s. of {eq}`odu_pv`.
220220

221-
The optimal action in state $s$ can be thought of as a part of a **policy** that maps a
221+
The optimal action in state $s$ can be thought of as a part of a **policy** that maps a
222222
state into an action.
223223

224224
Given *any* $s$, we can read off the corresponding best choice (accept or
@@ -351,7 +351,7 @@ Moreover, it's immediate from the definition of $T$ that this fixed
351351
point is $v^*$.
352352

353353
A second implication of the Banach contraction mapping theorem is that
354-
$\{ T^k v \}$ converges to the fixed point $v^*$ regardless of the initial
354+
$\{ T^k v \}$ converges to the fixed point $v^*$ regardless of the initial
355355
$v \in \mathbb R^n$.
356356

357357
### Implementation
@@ -386,7 +386,7 @@ We are going to use Numba to accelerate our code.
386386

387387
* See, in particular, the discussion of `@jitclass` in [our lecture on Numba](https://python-programming.quantecon.org/numba.html).
388388

389-
The following helps Numba by providing some information about types
389+
The following helps Numba by providing some information about types
390390

391391
```{code-cell} python3
392392
mccall_data = [
@@ -490,15 +490,15 @@ def compute_reservation_wage(mcm,
490490
n = len(w)
491491
v = w / (1 - β) # initial guess
492492
v_next = np.empty_like(v)
493-
i = 0
493+
j = 0
494494
error = tol + 1
495-
while i < max_iter and error > tol:
495+
while j < max_iter and error > tol:
496496
497497
for i in range(n):
498498
v_next[i] = np.max(mcm.state_action_values(i, v))
499499
500500
error = np.max(np.abs(v_next - v))
501-
i += 1
501+
j += 1
502502
503503
v[:] = v_next # copy contents into v
504504

0 commit comments

Comments
 (0)