You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix notation conflict: change volatility parameter from s to ν (#728)
Changed the shock scale parameter from 's' to 'ν' (Greek letter nu) to
resolve the naming conflict with savings (s = x - c). This makes the code
more readable and consistent with mathematical notation conventions.
Changes:
- Updated mathematical notation in text to use \nu instead of s
- Changed Model NamedTuple field from 's' to 'ν'
- Updated create_model function parameter from 's' to 'ν'
- Modified shock calculation to use ν
- Simplified Model instantiation to use positional arguments
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: lectures/cake_eating_stochastic.md
+70-89Lines changed: 70 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,8 @@ stochastically.
34
34
35
35
We can think of this cake as a harvest that regrows if we save some seeds.
36
36
37
-
Specifically, if we save (invest) part of today's cake, it grows into next
38
-
period's cake according to a stochastic production process.
37
+
Specifically, if we save and invest part of today's harvest $x_t$, it grows into next
38
+
period's harvest $x_{t+1}$ according to a stochastic production process.
39
39
40
40
```{note}
41
41
The term "cake eating" is not such a good fit now that we have a stochastic and
@@ -81,55 +81,49 @@ import matplotlib.pyplot as plt
81
81
import numpy as np
82
82
from scipy.interpolate import interp1d
83
83
from scipy.optimize import minimize_scalar
84
+
from typing import NamedTuple, Callable
85
+
84
86
```
85
87
86
88
## The Model
87
89
88
90
```{index} single: Stochastic Cake Eating; Model
89
91
```
90
92
91
-
Consider an agent who owns an amount $x_t \in \mathbb R_+ := [0, \infty)$ of a consumption good at time $t$.
93
+
Here we described the new model and the optimization problem.
92
94
93
-
This output can either be consumed or invested.
95
+
### Setup
94
96
95
-
When the good is invested, it is transformed one-for-one into capital.
97
+
Consider an agent who owns an amount $x_t \in \mathbb R_+ := [0, \infty)$ of a consumption good at time $t$.
96
98
97
-
The resulting capital stock, denoted here by $k_{t+1}$, will then be used for production.
99
+
This output can either be consumed or saved and used for production.
98
100
99
101
Production is stochastic, in that it also depends on a shock $\xi_{t+1}$ realized at the end of the current period.
100
102
101
103
Next period output is
102
104
103
105
$$
104
-
x_{t+1} := f(k_{t+1}) \xi_{t+1}
106
+
x_{t+1} := f(s_t) \xi_{t+1}
105
107
$$
106
108
107
-
where $f \colon \mathbb R_+ \to \mathbb R_+$ is called the production function.
108
-
109
-
The resource constraint is
109
+
where $f \colon \mathbb R_+ \to \mathbb R_+$ is the **production function** and
110
110
111
111
```{math}
112
112
:label: outcsdp0
113
113
114
-
k_{t+1} + c_t \leq x_t
114
+
s_t = x_t - c_t
115
115
```
116
116
117
-
and all variables are required to be nonnegative.
117
+
is **current savings**.
118
118
119
-
### Assumptions and Comments
119
+
and all variables are required to be nonnegative.
120
120
121
121
In what follows,
122
122
123
123
* The sequence $\{\xi_t\}$ is assumed to be IID.
124
124
* The common distribution of each $\xi_t$ will be denoted by $\phi$.
125
125
* The production function $f$ is assumed to be increasing and continuous.
126
-
* Depreciation of capital is not made explicit but can be incorporated into the production function.
127
-
128
-
While many other treatments of stochastic consumption-saving models use $k_t$ as the state variable, we will use $x_t$.
129
126
130
-
This will allow us to treat a stochastic model while maintaining only one state variable.
131
-
132
-
We consider alternative states and timing specifications in some of our other lectures.
133
127
134
128
### Optimization
135
129
@@ -157,21 +151,20 @@ where
157
151
* $u$ is a bounded, continuous and strictly increasing utility function and
158
152
* $\beta \in (0, 1)$ is a discount factor.
159
153
160
-
In {eq}`og_conse` we are assuming that the resource constraint {eq}`outcsdp0` holds with equality --- which is reasonable because $u$ is strictly increasing and no output will be wasted at the optimum.
161
-
162
154
In summary, the agent's aim is to select a path $c_0, c_1, c_2, \ldots$ for consumption that is
163
155
164
156
1. nonnegative,
165
-
1. feasible in the sense of {eq}`outcsdp0`,
157
+
1. feasible,
166
158
1. optimal, in the sense that it maximizes {eq}`texs0_og2` relative to all other feasible consumption sequences, and
167
-
1.**adapted**, in the sense that the action $c_t$ depends only on
168
-
observable outcomes, not on future outcomes such as $\xi_{t+1}$.
159
+
1.**adapted**, in the sense that the current action $c_t$ depends only on current and historical outcomes, not on future outcomes such as $\xi_{t+1}$.
169
160
170
161
In the present context
171
162
172
163
* $x_t$ is called the **state** variable --- it summarizes the "state of the world" at the start of each period.
173
164
* $c_t$ is called the **control** variable --- a value chosen by the agent each period after observing the state.
174
165
166
+
167
+
175
168
### The Policy Function Approach
176
169
177
170
```{index} single: Stochastic Cake Eating; Policy Function Approach
@@ -183,14 +176,10 @@ A policy function is a map from past and present observables into current action
183
176
184
177
We'll be particularly interested in **Markov policies**, which are maps from the current state $x_t$ into a current action $c_t$.
185
178
186
-
For dynamic programming problems such as this one (in fact for any [Markov decision process](https://en.wikipedia.org/wiki/Markov_decision_process)), the optimal policy is always a Markov policy.
179
+
For dynamic programming problems such as this one, the optimal policy is always a Markov policy (see, e.g., [DP1](https://dp.quantecon.org/)).
187
180
188
-
In other words, the current state $x_t$ provides a [sufficient statistic](https://en.wikipedia.org/wiki/Sufficient_statistic)
189
-
for the history in terms of making an optimal decision today.
190
-
191
-
This is quite intuitive, but if you wish you can find proofs in texts such as {cite}`StokeyLucas1989` (section 4.1).
192
-
193
-
Hereafter we focus on finding the best Markov policy.
181
+
In other words, the current state $x_t$ provides a sufficient statistic for the history
182
+
in terms of making an optimal decision today.
194
183
195
184
In our context, a Markov policy is a function $\sigma \colon
196
185
\mathbb R_+ \to \mathbb R_+$, with the understanding that states are mapped to actions via
@@ -199,7 +188,7 @@ $$
199
188
c_t = \sigma(x_t) \quad \text{for all } t
200
189
$$
201
190
202
-
In what follows, we will call $\sigma$ a *feasible consumption policy* if it satisfies
191
+
In what follows, we will call $\sigma$ a **feasible consumption policy** if it satisfies
203
192
204
193
```{math}
205
194
:label: idp_fp_og2
@@ -246,9 +235,11 @@ The aim is to select a policy that makes this number as large as possible.
246
235
247
236
The next section covers these ideas more formally.
248
237
238
+
239
+
249
240
### Optimality
250
241
251
-
The $\sigma$ associated with a given policy $\sigma$ is the mapping defined by
242
+
The lifetime value $v_{\sigma}$ associated with a given policy $\sigma$ is the mapping defined by
252
243
253
244
```{math}
254
245
:label: vfcsdp00
@@ -259,8 +250,7 @@ v_{\sigma}(x) =
259
250
260
251
when $\{x_t\}$ is given by {eq}`firstp0_og2` with $x_0 = x$.
261
252
262
-
In other words, it is the lifetime value of following policy $\sigma$
263
-
starting at initial condition $x$.
253
+
In other words, it is the lifetime value of following policy $\sigma$ forever, starting at initial condition $x$.
264
254
265
255
The **value function** is then defined as
266
256
@@ -270,15 +260,17 @@ The **value function** is then defined as
0 commit comments