Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ca651b0
ENH: Migrate to sphinx-exercise
mmcky Jun 3, 2022
fcc315f
update a* lectures
mmcky Jun 3, 2022
c90cc81
update c*.md lectures
mmcky Jun 3, 2022
9aca0b1
add :class: dropdown for solutions
mmcky Jun 3, 2022
5b04fa2
update labels for exercises to be unique
mmcky Jun 6, 2022
3235eea
update labels for exercises to be unique
mmcky Jun 6, 2022
7a8cb63
update labels for exercises to be unique
mmcky Jun 6, 2022
9c714bb
update labels for exercises to be unique
mmcky Jun 6, 2022
392790e
[career] fix nested directives issue
mmcky Jun 6, 2022
b62e796
update f*.md lectures
mmcky Jun 6, 2022
3ad8153
update h*.md lectures
mmcky Jun 6, 2022
f6cac05
fix issue in f*.md
mmcky Jun 6, 2022
819a4d2
update i*.md lectures
mmcky Jun 6, 2022
4de98fd
update j*.md lectures
mmcky Jun 6, 2022
e4300ce
fix broken reference to exercise
mmcky Jun 6, 2022
f629ba8
update k*.md lectures
mmcky Jun 6, 2022
87dd205
update m*.md lectures
mmcky Jun 6, 2022
e55a513
fix lqcontrol
mmcky Jun 6, 2022
ad6a211
update o*.md lectures
mmcky Jun 7, 2022
ecadde1
update p*.md lectures
mmcky Jun 7, 2022
326d1f2
fix optgrowth_fast
mmcky Jun 7, 2022
5324528
update r*.md lectures
mmcky Jun 7, 2022
99b4c0b
fix typo
mmcky Jun 7, 2022
2b680b5
update s*.md lectures
mmcky Jun 7, 2022
158c322
update u*.md lectures
mmcky Jun 7, 2022
fed170d
update w*.md lectures
mmcky Jun 7, 2022
864d789
Update m*.md and quality fixes
mmcky Jun 8, 2022
235b20c
update finite_markove tags to fm_ instead of mc_
mmcky Jun 8, 2022
788efc5
Revert "update finite_markove tags to fm_ instead of mc_"
mmcky Jun 8, 2022
9c42ec3
update exercise tag names to fm_ from mc_
mmcky Jun 8, 2022
bb013df
fix issue with markov_asset
mmcky Jun 8, 2022
70c4cef
update exercise links
mmcky Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ latex:
targetname: quantecon-python.tex

sphinx:
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinxcontrib.youtube, sphinx.ext.todo]
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinxcontrib.youtube, sphinx.ext.todo, sphinx_exercise, sphinx_togglebutton]
config:
nb_render_priority:
html:
Expand Down
37 changes: 31 additions & 6 deletions lectures/ar1_processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ important concept for statistics and simulation.

## Exercises

### Exercise 1
```{exercise}
:label: ar1p_ex1

Let $k$ be a natural number.

Expand Down Expand Up @@ -355,8 +356,11 @@ $$
when $m$ is large.

Confirm this by simulation at a range of $k$ using the default parameters from the lecture.
```


### Exercise 2
```{exercise}
:label: ar1p_ex2

Write your own version of a one dimensional [kernel density
estimator](https://en.wikipedia.org/wiki/Kernel_density_estimation),
Expand Down Expand Up @@ -398,8 +402,11 @@ Use $n=500$.

Make a comment on your results. (Do you think this is a good estimator
of these distributions?)
```


### Exercise 3
```{exercise}
:label: ar1p_ex3

In the lecture we discussed the following fact: for the $AR(1)$ process

Expand Down Expand Up @@ -438,10 +445,14 @@ color) as follows:
Try this for $n=2000$ and confirm that the
simulation based estimate of $\psi_{t+1}$ does converge to the
theoretical distribution.
```


## Solutions

### Exercise 1
```{solution-start} ar1p_ex1
:class: dropdown
```

```{code-cell} python3
from numba import njit
Expand Down Expand Up @@ -479,7 +490,13 @@ ax.legend()
plt.show()
```

### Exercise 2
```{solution-end}
```


```{solution-start} ar1p_ex2
:class: dropdown
```

Here is one solution:

Expand Down Expand Up @@ -532,7 +549,13 @@ for α, β in parameter_pairs:
We see that the kernel density estimator is effective when the underlying
distribution is smooth but less so otherwise.

### Exercise 3
```{solution-end}
```


```{solution-start} ar1p_ex3
:class: dropdown
```

Here is our solution

Expand Down Expand Up @@ -579,3 +602,5 @@ plt.show()
The simulated distribution approximately coincides with the theoretical
distribution, as predicted.

```{solution-end}
```
24 changes: 20 additions & 4 deletions lectures/cake_eating_numerical.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ This is due to

## Exercises

### Exercise 1
```{exercise}
:label: cen_ex1

Try the following modification of the problem.

Expand All @@ -500,15 +501,22 @@ where $\alpha$ is a parameter satisfying $0 < \alpha < 1$.
Make the required changes to value function iteration code and plot the value and policy functions.

Try to reuse as much code as possible.
```


### Exercise 2
```{exercise}
:label: cen_ex2

Implement time iteration, returning to the original case (i.e., dropping the
modification in the exercise above).
```


## Solutions

### Exercise 1
```{solution-start} cen_ex1
:class: dropdown
```

We need to create a class to hold our primitives and return the right hand side of the Bellman equation.

Expand Down Expand Up @@ -582,7 +590,13 @@ plt.show()

Consumption is higher when $\alpha < 1$ because, at least for large $x$, the return to savings is lower.

### Exercise 2
```{solution-end}
```


```{solution-start} cen_ex2
:class: dropdown
```

Here's one way to implement time iteration.

Expand Down Expand Up @@ -670,3 +684,5 @@ ax.legend(fontsize=12)
plt.show()
```

```{solution-end}
```
9 changes: 6 additions & 3 deletions lectures/cake_eating_problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ Combining this fact with {eq}`bellman_envelope` recovers the Euler equation.

## Exercises

### Exercise 1
```{exercise}
:label: cep_ex1

How does one obtain the expressions for the value function and optimal policy
given in {eq}`crra_vstar` and {eq}`crra_opt_pol` respectively?
Expand All @@ -523,10 +524,12 @@ Starting from this conjecture, try to obtain the solutions {eq}`crra_vstar` and

In doing so, you will need to use the definition of the value function and the
Bellman equation.
```

## Solutions

### Exercise 1
```{solution} cep_ex1
:class: dropdown

We start with the conjecture $c_t^*=\theta x_t$, which leads to a path
for the state variable (cake size) given by
Expand Down Expand Up @@ -611,4 +614,4 @@ v^*(x_t) = \left(1-\beta^\frac{1}{\gamma}\right)^{-\gamma}u(x_t)
$$

Our claims are now verified.

```
44 changes: 34 additions & 10 deletions lectures/career.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ the worker cannot change careers without changing jobs.

## Exercises

(career_ex1)=
### Exercise 1
```{exercise-start}
:label: career_ex1
```

Using the default parameterization in the class `CareerWorkerProblem`,
generate and plot typical sample paths for $\theta$ and $\epsilon$
Expand All @@ -372,13 +373,16 @@ when the worker follows the optimal policy.
In particular, modulo randomness, reproduce the following figure (where the horizontal axis represents time)

```{figure} /_static/lecture_specific/career/career_solutions_ex1_py.png

```

Hint: To generate the draws from the distributions $F$ and $G$, use `quantecon.random.draw()`.

(career_ex2)=
### Exercise 2
```{exercise-end}
```


```{exercise}
:label: career_ex2

Let's now consider how long it takes for the worker to settle down to a
permanent job, given a starting point of $(\theta, \epsilon) = (0, 0)$.
Expand All @@ -402,16 +406,21 @@ $$
Collect 25,000 draws of this random variable and compute the median (which should be about 7).

Repeat the exercise with $\beta=0.99$ and interpret the change.
```


(career_ex3)=
### Exercise 3
```{exercise}
:label: career_ex3

Set the parameterization to `G_a = G_b = 100` and generate a new optimal policy
figure -- interpret.
```

## Solutions

### Exercise 1
```{solution-start} career_ex1
:class: dropdown
```

Simulate job/career paths.

Expand Down Expand Up @@ -455,7 +464,13 @@ plt.legend()
plt.show()
```

### Exercise 2
```{solution-end}
```


```{solution-start} career_ex2
:class: dropdown
```

The median for the original parameterization can be computed as follows

Expand Down Expand Up @@ -498,7 +513,13 @@ The medians are subject to randomness but should be about 7 and 14 respectively.

Not surprisingly, more patient workers will wait longer to settle down to their final job.

### Exercise 3
```{solution-end}
```


```{solution-start} career_ex3
:class: dropdown
```

```{code-cell} python3
cw = CareerWorkerProblem(G_a=100, G_b=100)
Expand All @@ -522,3 +543,6 @@ In the new figure, you see that the region for which the worker
stays put has grown because the distribution for $\epsilon$
has become more concentrated around the mean, making high-paying jobs
less realistic.

```{solution-end}
```
11 changes: 11 additions & 0 deletions lectures/cass_koopmans_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,28 @@ state in which $f'(K)=\rho +\delta$.

### Exercise

```{exercise}
:label: ck1_ex1

- Plot the optimal consumption, capital, and saving paths when the
initial capital level begins at 1.5 times the steady state level
as we shoot towards the steady state at $T=130$.
- Why does the saving rate respond as it does?
```

### Solution

```{solution-start} ck1_ex1
:class: dropdown
```

```{code-cell} python3
plot_saving_rate(pp, 0.3, k_ss*1.5, [130], k_ter=k_ss, k_ss=k_ss, s_ss=s_ss)
```

```{solution-end}
```

## Concluding Remarks

In {doc}`Cass-Koopmans Competitive Equilibrium <cass_koopmans_2>`, we study a decentralized version of an economy with exactly the same
Expand Down
10 changes: 8 additions & 2 deletions lectures/coleman_policy_iter.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ and accuracy, at least for this model.

## Exercises

### Exercise 1
```{exercise}
:label: cpi_ex1

Solve the model with CRRA utility

Expand All @@ -435,10 +436,13 @@ $$
Set `γ = 1.5`.

Compute and plot the optimal policy.
```

## Solutions

### Exercise 1
```{solution-start} cpi_ex1
:class: dropdown
```

We use the class `OptimalGrowthModel_CRRA` from our {doc}`VFI lecture <optgrowth_fast>`.

Expand Down Expand Up @@ -468,3 +472,5 @@ ax.legend()
plt.show()
```

```{solution-end}
```
Loading