From d299c1b15a8f0d4a7775172e8fc5dfd00121538a Mon Sep 17 00:00:00 2001 From: "Fernando J. Chaure" Date: Sat, 3 May 2025 18:56:01 -0300 Subject: [PATCH 1/5] fix small details --- lectures/software_engineering/need_for_speed.md | 4 +--- lectures/tools_and_techniques/geom_series.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lectures/software_engineering/need_for_speed.md b/lectures/software_engineering/need_for_speed.md index 62a5b371..c1a779e6 100644 --- a/lectures/software_engineering/need_for_speed.md +++ b/lectures/software_engineering/need_for_speed.md @@ -272,7 +272,7 @@ f(x) = x > 0.0 ? x : 0.0 Which shows that, when called with an integer, the type could be that integer or the floating point `0.0`. -On the other hand, if we use change the function to return `0` if x <= 0, it is type-unstable with floating point. +On the other hand, if we use change the function to return `0` if `x <= 0`, it is type-unstable with floating point. ```{code-cell} julia f(x) = x > 0.0 ? x : 0 @@ -281,8 +281,6 @@ f(x) = x > 0.0 ? x : 0 The solution is to use the `zero(x)` function which returns the additive identity element of type `x`. -On the other hand, if we change the function to return `0` if `x <= 0`, it is type-unstable with floating point. - ```{code-cell} julia @show zero(2.3) @show zero(4) diff --git a/lectures/tools_and_techniques/geom_series.md b/lectures/tools_and_techniques/geom_series.md index d6643c6d..e78e596a 100644 --- a/lectures/tools_and_techniques/geom_series.md +++ b/lectures/tools_and_techniques/geom_series.md @@ -228,7 +228,7 @@ D_i = (1 - r)^i D_0 \ \text{ for } i \geq 0 ``` Equation {eq}`geomseries` expresses $D_i$ as the $i$ th term in the -product of $D_0$ and the geometric series +product of $D_0$ and the geometric progression $$ 1, (1-r), (1-r)^2, \cdots From 9fe80c1e590617a56fd5004991d8f2454170d15d Mon Sep 17 00:00:00 2001 From: "Fernando J. Chaure" Date: Tue, 13 May 2025 20:36:44 -0300 Subject: [PATCH 2/5] small fixes --- lectures/tools_and_techniques/geom_series.md | 2 +- lectures/tools_and_techniques/stationary_densities.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lectures/tools_and_techniques/geom_series.md b/lectures/tools_and_techniques/geom_series.md index e78e596a..28111c73 100644 --- a/lectures/tools_and_techniques/geom_series.md +++ b/lectures/tools_and_techniques/geom_series.md @@ -228,7 +228,7 @@ D_i = (1 - r)^i D_0 \ \text{ for } i \geq 0 ``` Equation {eq}`geomseries` expresses $D_i$ as the $i$ th term in the -product of $D_0$ and the geometric progression +product of $D_0$ and the geometric sequence $$ 1, (1-r), (1-r)^2, \cdots diff --git a/lectures/tools_and_techniques/stationary_densities.md b/lectures/tools_and_techniques/stationary_densities.md index 26be7a12..e1594b71 100644 --- a/lectures/tools_and_techniques/stationary_densities.md +++ b/lectures/tools_and_techniques/stationary_densities.md @@ -29,9 +29,9 @@ kernelspec: ## Overview -In a {doc}`previous lecture <../introduction_dynamics/finite_markov>` we learned about finite Markov chains, a relatively elementary class of stochastic dynamic models. +In this lecture, we will study the case of continuous (i.e., uncountable) state Markov chains. -The present lecture extends this analysis to continuous (i.e., uncountable) state Markov chains. +A {doc}`previous lecture <../introduction_dynamics/finite_markov>` will cover finite Markov chains, a relatively elementary class of stochastic dynamic models. Most stochastic dynamic models studied by economists either fit directly into this class or can be represented as continuous state Markov chains after minor modifications. From 896e7169fc6a224fc058a253fb144b5fd6f9baa2 Mon Sep 17 00:00:00 2001 From: "Fernando J. Chaure" Date: Tue, 13 May 2025 20:37:22 -0300 Subject: [PATCH 3/5] removes note about mouse rotation --- lectures/tools_and_techniques/lln_clt.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lectures/tools_and_techniques/lln_clt.md b/lectures/tools_and_techniques/lln_clt.md index 48ccba50..4b702995 100644 --- a/lectures/tools_and_techniques/lln_clt.md +++ b/lectures/tools_and_techniques/lln_clt.md @@ -518,10 +518,6 @@ As expected, the distribution smooths out into a bell curve as $n$ increases. We leave you to investigate its contents if you wish to know more. -If you run the file from the ordinary Julia or IJulia shell, the figure should pop up in a -window that you can rotate with your mouse, giving different views on the -density sequence. - (multivariate_clt)= ### The Multivariate Case From 84bed89508cf563385db3af47bd7e387aba696f6 Mon Sep 17 00:00:00 2001 From: "Fernando J. Chaure" Date: Sat, 17 May 2025 20:15:55 -0300 Subject: [PATCH 4/5] more change stationaty densities --- .../stationary_densities.md | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lectures/tools_and_techniques/stationary_densities.md b/lectures/tools_and_techniques/stationary_densities.md index e1594b71..7c18399d 100644 --- a/lectures/tools_and_techniques/stationary_densities.md +++ b/lectures/tools_and_techniques/stationary_densities.md @@ -54,8 +54,7 @@ In particular, * Is there a notion of "steady state" or "long run equilibrium" that's applicable to the model? * If so, how can we compute it? -Answering these questions will lead us to revisit many of the topics that occupied us in the finite state case, -such as simulation, distribution dynamics, stability, ergodicity, etc. +Answering these questions will lead us to explore topics such as simulation, distribution dynamics, stability, and ergodicity. ```{note} For some people, the term "Markov chain" always refers to a process with a @@ -89,9 +88,7 @@ Once we've built some intuition we'll cover the general case. ### Definitions and Basic Properties -In our {doc}`lecture on finite Markov chains <../introduction_dynamics/finite_markov>`, we studied discrete time Markov chains that evolve on a finite state space $S$. - -In this setting, the dynamics of the model are described by a stochastic matrix --- a nonnegative square matrix $P = P[i, j]$ such that each row $P[i, \cdot]$ sums to one. +We can start by considering a finite state space $S$. In this setting, the dynamics of the model are described by a stochastic matrix --- a nonnegative square matrix $P = P[i, j]$ such that each row $P[i, \cdot]$ sums to one. The interpretation of $P$ is that $P[i, j]$ represents the probability of transitioning from state $i$ to state $j$ in one @@ -271,16 +268,15 @@ $\sigma(x) = s f(x)$ is strictly positive for all $s$ as required) ### Distribution Dynamics -In {ref}`this section ` of our lecture on **finite** Markov chains, we -asked the following question: If +Later in {ref}`another section ` of our lecture on **finite** Markov chains, we +will explore the following question: If 1. $\{X_t\}$ is a Markov chain with stochastic matrix $P$ 1. the distribution of $X_t$ is known to be $\psi_t$ then what is the distribution of $X_{t+1}$? -Letting $\psi_{t+1}$ denote the distribution of $X_{t+1}$, the -answer {ref}`we gave ` was that +Letting $\psi_{t+1}$ denote the distribution of $X_{t+1}$, we will show that $$ \psi_{t+1}[j] = \sum_{i \in S} P[i,j] \psi_t[i] @@ -526,7 +522,7 @@ Notice that the sequence of densities shown in the figure seems to be converging --- more on this in just a moment. Another quick comment is that each of these distributions could be interpreted -as a cross sectional distribution (recall {ref}`this discussion `). +as a cross sectional distribution (see {ref}`this discussion `). ## Beyond Densities @@ -606,17 +602,12 @@ One good option is simulation as before, combined with the [empirical distributi ## Stability -In our {doc}`lecture <../introduction_dynamics/finite_markov>` on finite Markov chains we also studied stationarity, stability and ergodicity. - -Here we will cover the same topics for the continuous case. - -We will, however, treat only the density case (as in {ref}`this section `), where the stochastic kernel is a family of densities. +In this section, we will explore three concepts: stationarity, stability, and ergodicity. Our focus will be specifically on the density case (as in {ref}`this section `), where the stochastic kernel is a family of densities. The general case is relatively similar --- references are given below. -The general case is relatively similar --- references are given below. ### Theoretical Results -Analogous to {ref}`the finite case `, given a stochastic kernel $p$ and corresponding Markov operator as +Given a stochastic kernel $p$ and corresponding Markov operator as defined in {eq}`def_dmo`, a density $\psi^*$ on $S$ is called *stationary* for $P$ if it is a fixed point of the operator $P$. @@ -635,7 +626,7 @@ the distribution of $X_0$ is $\psi^*$, then, in view of Hence $\psi^*$ is the stochastic equivalent of a steady state. -In the finite case, we learned that at least one stationary distribution exists, although there may be many. +In the finite case, we will learn that at least one stationary distribution exists, although there may be many. When the state space is infinite, the situation is more complicated. From 4bf4424089ebe3afbd9e745642d334dd519886b8 Mon Sep 17 00:00:00 2001 From: "Fernando J. Chaure" Date: Sun, 18 May 2025 19:50:51 -0300 Subject: [PATCH 5/5] fix solution --- lectures/tools_and_techniques/stationary_densities.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lectures/tools_and_techniques/stationary_densities.md b/lectures/tools_and_techniques/stationary_densities.md index 7c18399d..28b3163c 100644 --- a/lectures/tools_and_techniques/stationary_densities.md +++ b/lectures/tools_and_techniques/stationary_densities.md @@ -991,7 +991,7 @@ T = 40 # Compute density of k_t at 1,...,T+1 xmax = 6.5 ygrid = range(0.01, xmax, length = 150) laes_plot = zeros(length(ygrid), 4T) -colors = [] +colors = zeros(RGBA,1,4*T); for i in 1:4 k = zeros(n, T) A = rand!(phi, zeros(n, T)) @@ -1009,13 +1009,11 @@ for i in 1:4 for j in 1:T psi = laes[j] laes_plot[:, ind] = lae_est(psi, ygrid) + colors[ind]=RGBA(0, 0, 0, 1 - (j - 1) / T) ind = ind + 4 - push!(colors, RGBA(0, 0, 0, 1 - (j - 1) / T)) end end -#colors = reshape(reshape(colors, T, 4)', 4*T, 1) -colors = reshape(colors, 1, length(colors)) plot(ygrid, laes_plot, layout = (2, 2), color = colors, legend = :none, xlabel = "capital", xlims = (0, xmax)) ```