├── postBuild ├── .gitignore ├── README.md ├── getting_started_julia ├── us_cities.txt ├── index.ipynb └── getting_started.ipynb ├── search.ipynb ├── 404.ipynb ├── status.ipynb ├── continuous_time └── index.ipynb ├── multi_agent_models ├── index_grad.ipynb ├── index_undergrad.ipynb └── index.ipynb ├── dynamic_programming_squared └── index.ipynb ├── time_series_models ├── index.ipynb └── index_grad.ipynb ├── Project.toml ├── tools_and_techniques ├── index_undergrad.ipynb ├── index_grad.ipynb └── index.ipynb ├── index.ipynb ├── troubleshooting.ipynb ├── index_undergrad.ipynb ├── dynamic_programming ├── index_undergrad.ipynb ├── index_grad.ipynb ├── index.ipynb └── short_path.ipynb ├── index_postgrad.ipynb ├── more_julia ├── index.ipynb └── version_control.ipynb ├── index_toc.ipynb ├── about_lectures.ipynb └── zreferences.ipynb /postBuild: -------------------------------------------------------------------------------- 1 | julia -e 'using Pkg; pkg"add InstantiateFromURL"' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _static 2 | **/.DS_Store 3 | update.sh 4 | **/.ipynb_checkpoints -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **DEPRECATED** 2 | 3 | The new repository for notebooks is https://github.com/QuantEcon/lecture-julia.notebooks 4 | 5 | -------------------------------------------------------------------------------- /getting_started_julia/us_cities.txt: -------------------------------------------------------------------------------- 1 | new york: 8244910 2 | los angeles: 3819702 3 | chicago: 2707120 4 | houston: 2145146 5 | philadelphia: 1536471 6 | phoenix: 1469471 7 | san antonio: 1359758 8 | san diego: 1326179 9 | dallas: 1223229 -------------------------------------------------------------------------------- /search.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# Search\n", 16 | "\n", 17 | "\n", 18 | "
\n", 19 | "
" 20 | ] 21 | } 22 | ], 23 | "metadata": { 24 | "date": 1591310626.1592665, 25 | "download_nb": 1, 26 | "download_nb_path": "https://julia.quantecon.org/", 27 | "filename": "search.rst", 28 | "filename_with_path": "search", 29 | "kernelspec": { 30 | "display_name": "Julia 1.4.2", 31 | "language": "julia", 32 | "name": "julia-1.4" 33 | }, 34 | "language_info": { 35 | "file_extension": ".jl", 36 | "mimetype": "application/julia", 37 | "name": "julia", 38 | "version": "1.4.2" 39 | }, 40 | "title": "Search" 41 | }, 42 | "nbformat": 4, 43 | "nbformat_minor": 2 44 | } 45 | -------------------------------------------------------------------------------- /404.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# Page Not Found\n", 16 | "\n", 17 | "\n", 18 | "\n", 19 | "We couldn’t find the page you were looking for.\n", 20 | "\n", 21 | "Please check the URL or try a link below:\n", 22 | "\n", 23 | "- [Home](/) \n", 24 | "- [QuantEcon](https://quantecon.org/) \n", 25 | "- [Quantitative Economics with Python](https://python.quantecon.org/) \n", 26 | "- [Quantitative Economics with Julia](https://julia.quantecon.org/) \n", 27 | "- [QuantEcon DataScience](https://datascience.quantecon.org/) \n", 28 | "- [Forum](http://discourse.quantecon.org/) \n", 29 | "- [Contact us](mailto:contact@quantecon.org) " 30 | ] 31 | } 32 | ], 33 | "metadata": { 34 | "date": 1591310613.966008, 35 | "download_nb": 1, 36 | "download_nb_path": "https://julia.quantecon.org/", 37 | "filename": "404.rst", 38 | "filename_with_path": "404", 39 | "kernelspec": { 40 | "display_name": "Julia 1.4.2", 41 | "language": "julia", 42 | "name": "julia-1.4" 43 | }, 44 | "language_info": { 45 | "file_extension": ".jl", 46 | "mimetype": "application/julia", 47 | "name": "julia", 48 | "version": "1.4.2" 49 | }, 50 | "title": "Page Not Found" 51 | }, 52 | "nbformat": 4, 53 | "nbformat_minor": 2 54 | } 55 | -------------------------------------------------------------------------------- /status.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# Lecture Status\n", 16 | "\n", 17 | "\n", 18 | "

The badges below show which lectures are currently passing their execution test (i.e., executing without errors).

\n", 19 | "

The lecture code checker was last run: N/A

\n", 20 | "
\n", 21 | "
\n", 22 | "
\n", 23 | "

The code checker is run on a t2.small Amazon EC2 instance. This is an instance with a single CPU and 2 GiB of Memory.

\n", 24 | "

You should achieve faster run times on many common laptops and desktops.

" 25 | ] 26 | } 27 | ], 28 | "metadata": { 29 | "date": 1591310626.29732, 30 | "download_nb": 1, 31 | "download_nb_path": "https://julia.quantecon.org/", 32 | "filename": "status.rst", 33 | "filename_with_path": "status", 34 | "kernelspec": { 35 | "display_name": "Julia 1.4.2", 36 | "language": "julia", 37 | "name": "julia-1.4" 38 | }, 39 | "language_info": { 40 | "file_extension": ".jl", 41 | "mimetype": "application/julia", 42 | "name": "julia", 43 | "version": "1.4.2" 44 | }, 45 | "title": "Lecture Status" 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 2 49 | } 50 | -------------------------------------------------------------------------------- /continuous_time/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Modeling in Continuous Time\n", 21 | "\n", 22 | "This section of the course contains foundational mathematical and computational tools for working with continuous time deterministic and stochastic models." 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "## Lectures\n", 30 | "\n", 31 | "- [Modeling COVID 19 with Differential Equations](seir_model.html)\n", 32 | " - [Overview](seir_model.html#overview)\n", 33 | " - [The SEIR Model](seir_model.html#the-seir-model)\n", 34 | " - [Implementation](seir_model.html#id4)\n", 35 | " - [Experiments](seir_model.html#experiments)\n", 36 | " - [Ending Lockdown](seir_model.html#ending-lockdown)\n", 37 | "- [Modeling Shocks in COVID 19 with Stochastic Differential Equations](covid_sde.html)\n", 38 | " - [Overview](covid_sde.html#overview)\n", 39 | " - [The Basic SIR/SIRD Model](covid_sde.html#the-basic-sir-sird-model)\n", 40 | " - [Introduction to SDEs](covid_sde.html#introduction-to-sdes)\n", 41 | " - [Ending Lockdown](covid_sde.html#ending-lockdown)\n", 42 | " - [Reinfection](covid_sde.html#reinfection)" 43 | ] 44 | } 45 | ], 46 | "metadata": { 47 | "date": 1595546525.7022398, 48 | "download_nb": 1, 49 | "download_nb_path": "https://julia.quantecon.org/", 50 | "filename": "index.rst", 51 | "filename_with_path": "continuous_time/index", 52 | "kernelspec": { 53 | "display_name": "Julia 1.4.2", 54 | "language": "julia", 55 | "name": "julia-1.4" 56 | }, 57 | "language_info": { 58 | "file_extension": ".jl", 59 | "mimetype": "application/julia", 60 | "name": "julia", 61 | "version": "1.4.2" 62 | }, 63 | "next_doc": { 64 | "link": "seir_model", 65 | "title": "Modeling COVID 19 with Differential Equations" 66 | }, 67 | "prev_doc": { 68 | "link": "../dynamic_programming/discrete_dp", 69 | "title": "Discrete State Dynamic Programming" 70 | }, 71 | "site_title": "Quantitative Economics with Julia", 72 | "title": "Modeling in Continuous Time" 73 | }, 74 | "nbformat": 4, 75 | "nbformat_minor": 2 76 | } 77 | -------------------------------------------------------------------------------- /multi_agent_models/index_grad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Multiple Agent Models\n", 21 | "\n", 22 | "These lectures look at important economic models that also illustrate common\n", 23 | "equilibrium concepts." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Asset Pricing II: The Lucas Asset Pricing Model](lucas_model.html)\n", 33 | " - [Overview](lucas_model.html#overview)\n", 34 | " - [The Lucas Model](lucas_model.html#the-lucas-model)\n", 35 | " - [Exercises](lucas_model.html#exercises)\n", 36 | " - [Solutions](lucas_model.html#solutions)\n", 37 | "- [Uncertainty Traps](uncertainty_traps.html)\n", 38 | " - [Overview](uncertainty_traps.html#overview)\n", 39 | " - [The Model](uncertainty_traps.html#the-model)\n", 40 | " - [Implementation](uncertainty_traps.html#implementation)\n", 41 | " - [Results](uncertainty_traps.html#results)\n", 42 | " - [Exercises](uncertainty_traps.html#exercises)\n", 43 | " - [Solutions](uncertainty_traps.html#solutions)\n", 44 | " - [Exercise 2](uncertainty_traps.html#id6)\n", 45 | "- [The Aiyagari Model](aiyagari.html)\n", 46 | " - [Overview](aiyagari.html#overview)\n", 47 | " - [The Economy](aiyagari.html#the-economy)\n", 48 | " - [Firms](aiyagari.html#firms)\n", 49 | " - [Code](aiyagari.html#code)\n", 50 | "- [Default Risk and Income Fluctuations](arellano.html)\n", 51 | " - [Overview](arellano.html#overview)\n", 52 | " - [Structure](arellano.html#structure)\n", 53 | " - [Equilibrium](arellano.html#equilibrium)\n", 54 | " - [Computation](arellano.html#computation)\n", 55 | " - [Results](arellano.html#results)\n", 56 | " - [Exercises](arellano.html#exercises)\n", 57 | " - [Solutions](arellano.html#solutions)\n", 58 | "- [Globalization and Cycles](matsuyama.html)\n", 59 | " - [Overview](matsuyama.html#overview)\n", 60 | " - [Key Ideas](matsuyama.html#key-ideas)\n", 61 | " - [Model](matsuyama.html#model)\n", 62 | " - [Simulation](matsuyama.html#simulation)\n", 63 | " - [Exercises](matsuyama.html#exercises)\n", 64 | " - [Solutions](matsuyama.html#solutions)" 65 | ] 66 | } 67 | ], 68 | "metadata": { 69 | "date": 1591310624.9482324, 70 | "download_nb": 1, 71 | "download_nb_path": "https://julia.quantecon.org/", 72 | "filename": "index_grad.rst", 73 | "filename_with_path": "multi_agent_models/index_grad", 74 | "kernelspec": { 75 | "display_name": "Julia 1.4.2", 76 | "language": "julia", 77 | "name": "julia-1.4" 78 | }, 79 | "language_info": { 80 | "file_extension": ".jl", 81 | "mimetype": "application/julia", 82 | "name": "julia", 83 | "version": "1.4.2" 84 | }, 85 | "title": "Multiple Agent Models" 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 2 89 | } 90 | -------------------------------------------------------------------------------- /dynamic_programming_squared/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Dynamic Programming Squared\n", 21 | "\n", 22 | "Here we look at models in which a value function for one Bellman equation has as an argument the value function for another Bellman equation." 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "## Lectures\n", 30 | "\n", 31 | "- [Dynamic Stackelberg Problems](dyn_stack.html)\n", 32 | " - [Duopoly](dyn_stack.html#duopoly)\n", 33 | " - [The Stackelberg Problem](dyn_stack.html#the-stackelberg-problem)\n", 34 | " - [Stackelberg Plan](dyn_stack.html#stackelberg-plan)\n", 35 | " - [Recursive Representation of Stackelberg Plan](dyn_stack.html#recursive-representation-of-stackelberg-plan)\n", 36 | " - [Computing the Stackelberg Plan](dyn_stack.html#computing-the-stackelberg-plan)\n", 37 | " - [Exhibiting Time Inconsistency of Stackelberg Plan](dyn_stack.html#exhibiting-time-inconsistency-of-stackelberg-plan)\n", 38 | " - [Recursive Formulation of the Follower’s Problem](dyn_stack.html#recursive-formulation-of-the-follower-s-problem)\n", 39 | " - [Markov Perfect Equilibrium](dyn_stack.html#markov-perfect-equilibrium)\n", 40 | " - [MPE vs. Stackelberg](dyn_stack.html#mpe-vs-stackelberg)\n", 41 | "- [Optimal Taxation in an LQ Economy](lqramsey.html)\n", 42 | " - [Overview](lqramsey.html#overview)\n", 43 | " - [The Ramsey Problem](lqramsey.html#the-ramsey-problem)\n", 44 | " - [Implementation](lqramsey.html#implementation)\n", 45 | " - [Examples](lqramsey.html#examples)\n", 46 | " - [Exercises](lqramsey.html#exercises)\n", 47 | " - [Solutions](lqramsey.html#solutions)\n", 48 | "- [Optimal Taxation with State-Contingent Debt](opt_tax_recur.html)\n", 49 | " - [Overview](opt_tax_recur.html#overview)\n", 50 | " - [A Competitive Equilibrium with Distorting Taxes](opt_tax_recur.html#a-competitive-equilibrium-with-distorting-taxes)\n", 51 | " - [Recursive Formulation of the Ramsey problem](opt_tax_recur.html#recursive-formulation-of-the-ramsey-problem)\n", 52 | " - [Examples](opt_tax_recur.html#examples)\n", 53 | " - [Further Comments](opt_tax_recur.html#further-comments)\n", 54 | "- [Optimal Taxation without State-Contingent Debt](amss.html)\n", 55 | " - [Overview](amss.html#overview)\n", 56 | " - [Competitive Equilibrium with Distorting Taxes](amss.html#competitive-equilibrium-with-distorting-taxes)\n", 57 | " - [Recursive Version of AMSS Model](amss.html#recursive-version-of-amss-model)\n", 58 | " - [Examples](amss.html#examples)" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "date": 1591310618.2875726, 64 | "download_nb": 1, 65 | "download_nb_path": "https://julia.quantecon.org/", 66 | "filename": "index.rst", 67 | "filename_with_path": "dynamic_programming_squared/index", 68 | "kernelspec": { 69 | "display_name": "Julia 1.4.2", 70 | "language": "julia", 71 | "name": "julia-1.4" 72 | }, 73 | "language_info": { 74 | "file_extension": ".jl", 75 | "mimetype": "application/julia", 76 | "name": "julia", 77 | "version": "1.4.2" 78 | }, 79 | "title": "Dynamic Programming Squared" 80 | }, 81 | "nbformat": 4, 82 | "nbformat_minor": 2 83 | } 84 | -------------------------------------------------------------------------------- /multi_agent_models/index_undergrad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Multiple Agent Models\n", 21 | "\n", 22 | "These lectures look at important economic models that also illustrate common\n", 23 | "equilibrium concepts." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Schelling’s Segregation Model](schelling.html)\n", 33 | " - [Overview](schelling.html#overview)\n", 34 | " - [The Model](schelling.html#the-model)\n", 35 | " - [Results](schelling.html#results)\n", 36 | " - [Exercises](schelling.html#exercises)\n", 37 | " - [Solutions](schelling.html#solutions)\n", 38 | "- [A Lake Model of Employment and Unemployment](lake_model.html)\n", 39 | " - [Overview](lake_model.html#overview)\n", 40 | " - [The Model](lake_model.html#the-model)\n", 41 | " - [Implementation](lake_model.html#implementation)\n", 42 | " - [Dynamics of an Individual Worker](lake_model.html#dynamics-of-an-individual-worker)\n", 43 | " - [Endogenous Job Finding Rate](lake_model.html#endogenous-job-finding-rate)\n", 44 | " - [Exercises](lake_model.html#exercises)\n", 45 | " - [Solutions](lake_model.html#solutions)\n", 46 | "- [Rational Expectations Equilibrium](rational_expectations.html)\n", 47 | " - [Overview](rational_expectations.html#overview)\n", 48 | " - [Defining Rational Expectations Equilibrium](rational_expectations.html#defining-rational-expectations-equilibrium)\n", 49 | " - [Computation of an Equilibrium](rational_expectations.html#computation-of-an-equilibrium)\n", 50 | " - [Exercises](rational_expectations.html#exercises)\n", 51 | " - [Solutions](rational_expectations.html#solutions)\n", 52 | "- [Markov Perfect Equilibrium](markov_perf.html)\n", 53 | " - [Overview](markov_perf.html#overview)\n", 54 | " - [Background](markov_perf.html#background)\n", 55 | " - [Linear Markov perfect equilibria](markov_perf.html#linear-markov-perfect-equilibria)\n", 56 | " - [Application](markov_perf.html#application)\n", 57 | " - [Exercises](markov_perf.html#exercises)\n", 58 | " - [Solutions](markov_perf.html#solutions)\n", 59 | "- [Asset Pricing I: Finite State Models](markov_asset.html)\n", 60 | " - [Overview](markov_asset.html#overview)\n", 61 | " - [Pricing Models](markov_asset.html#pricing-models)\n", 62 | " - [Prices in the Risk Neutral Case](markov_asset.html#prices-in-the-risk-neutral-case)\n", 63 | " - [Asset Prices under Risk Aversion](markov_asset.html#asset-prices-under-risk-aversion)\n", 64 | " - [Exercises](markov_asset.html#exercises)\n", 65 | " - [Solutions](markov_asset.html#solutions)" 66 | ] 67 | } 68 | ], 69 | "metadata": { 70 | "date": 1591310624.9746335, 71 | "download_nb": 1, 72 | "download_nb_path": "https://julia.quantecon.org/", 73 | "filename": "index_undergrad.rst", 74 | "filename_with_path": "multi_agent_models/index_undergrad", 75 | "kernelspec": { 76 | "display_name": "Julia 1.4.2", 77 | "language": "julia", 78 | "name": "julia-1.4" 79 | }, 80 | "language_info": { 81 | "file_extension": ".jl", 82 | "mimetype": "application/julia", 83 | "name": "julia", 84 | "version": "1.4.2" 85 | }, 86 | "title": "Multiple Agent Models" 87 | }, 88 | "nbformat": 4, 89 | "nbformat_minor": 2 90 | } 91 | -------------------------------------------------------------------------------- /time_series_models/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "
\n", 8 | " \n", 9 | " \"QuantEcon\"\n", 10 | " \n", 11 | "
" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "# Time Series Models\n", 19 | "\n", 20 | "These lectures look at important concepts in time series that are used in economics." 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "## Lectures\n", 28 | "\n", 29 | "- [Covariance Stationary Processes](arma.html)\n", 30 | " - [Overview](arma.html#overview)\n", 31 | " - [Introduction](arma.html#introduction)\n", 32 | " - [Spectral Analysis](arma.html#id12)\n", 33 | " - [Implementation](arma.html#implementation)\n", 34 | "- [Estimation of Spectra](estspec.html)\n", 35 | " - [Overview](estspec.html#overview)\n", 36 | " - [Periodograms](estspec.html#periodograms)\n", 37 | " - [Smoothing](estspec.html#smoothing)\n", 38 | " - [Exercises](estspec.html#exercises)\n", 39 | " - [Solutions](estspec.html#solutions)\n", 40 | "- [Additive Functionals](additive_functionals.html)\n", 41 | " - [Overview](additive_functionals.html#overview)\n", 42 | " - [A Particular Additive Functional](additive_functionals.html#a-particular-additive-functional)\n", 43 | " - [Dynamics](additive_functionals.html#dynamics)\n", 44 | " - [Code](additive_functionals.html#code)\n", 45 | "- [Multiplicative Functionals](multiplicative_functionals.html)\n", 46 | " - [Overview](multiplicative_functionals.html#overview)\n", 47 | " - [A Log-Likelihood Process](multiplicative_functionals.html#a-log-likelihood-process)\n", 48 | " - [Benefits from Reduced Aggregate Fluctuations](multiplicative_functionals.html#benefits-from-reduced-aggregate-fluctuations)\n", 49 | "- [Classical Control with Linear Algebra](lu_tricks.html)\n", 50 | " - [Overview](lu_tricks.html#overview)\n", 51 | " - [A Control Problem](lu_tricks.html#a-control-problem)\n", 52 | " - [Finite Horizon Theory](lu_tricks.html#finite-horizon-theory)\n", 53 | " - [The Infinite Horizon Limit](lu_tricks.html#the-infinite-horizon-limit)\n", 54 | " - [Undiscounted Problems](lu_tricks.html#undiscounted-problems)\n", 55 | " - [Implementation](lu_tricks.html#implementation)\n", 56 | " - [Exercises](lu_tricks.html#exercises)\n", 57 | "- [Classical Filtering With Linear Algebra](classical_filtering.html)\n", 58 | " - [Overview](classical_filtering.html#overview)\n", 59 | " - [Infinite Horizon Prediction and Filtering Problems](classical_filtering.html#infinite-horizon-prediction-and-filtering-problems)\n", 60 | " - [Finite Dimensional Prediction](classical_filtering.html#finite-dimensional-prediction)\n", 61 | " - [Combined Finite Dimensional Control and Prediction](classical_filtering.html#combined-finite-dimensional-control-and-prediction)\n", 62 | " - [Exercises](classical_filtering.html#exercises)" 63 | ] 64 | } 65 | ], 66 | "metadata": { 67 | "date": 1591310626.8334455, 68 | "download_nb": 1, 69 | "download_nb_path": "https://julia.quantecon.org/", 70 | "filename": "index.rst", 71 | "filename_with_path": "time_series_models/index", 72 | "kernelspec": { 73 | "display_name": "Julia 1.4.2", 74 | "language": "julia", 75 | "name": "julia-1.4" 76 | }, 77 | "language_info": { 78 | "file_extension": ".jl", 79 | "mimetype": "application/julia", 80 | "name": "julia", 81 | "version": "1.4.2" 82 | }, 83 | "title": "Time Series Models" 84 | }, 85 | "nbformat": 4, 86 | "nbformat_minor": 2 87 | } 88 | -------------------------------------------------------------------------------- /time_series_models/index_grad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "
\n", 8 | " \n", 9 | " \"QuantEcon\"\n", 10 | " \n", 11 | "
" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "# Time Series Models\n", 19 | "\n", 20 | "These lectures look at important concepts in time series that are used in economics." 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "## Lectures\n", 28 | "\n", 29 | "- [Covariance Stationary Processes](arma.html)\n", 30 | " - [Overview](arma.html#overview)\n", 31 | " - [Introduction](arma.html#introduction)\n", 32 | " - [Spectral Analysis](arma.html#id12)\n", 33 | " - [Implementation](arma.html#implementation)\n", 34 | "- [Estimation of Spectra](estspec.html)\n", 35 | " - [Overview](estspec.html#overview)\n", 36 | " - [Periodograms](estspec.html#periodograms)\n", 37 | " - [Smoothing](estspec.html#smoothing)\n", 38 | " - [Exercises](estspec.html#exercises)\n", 39 | " - [Solutions](estspec.html#solutions)\n", 40 | "- [Additive Functionals](additive_functionals.html)\n", 41 | " - [Overview](additive_functionals.html#overview)\n", 42 | " - [A Particular Additive Functional](additive_functionals.html#a-particular-additive-functional)\n", 43 | " - [Dynamics](additive_functionals.html#dynamics)\n", 44 | " - [Code](additive_functionals.html#code)\n", 45 | "- [Multiplicative Functionals](multiplicative_functionals.html)\n", 46 | " - [Overview](multiplicative_functionals.html#overview)\n", 47 | " - [A Log-Likelihood Process](multiplicative_functionals.html#a-log-likelihood-process)\n", 48 | " - [Benefits from Reduced Aggregate Fluctuations](multiplicative_functionals.html#benefits-from-reduced-aggregate-fluctuations)\n", 49 | "- [Classical Control with Linear Algebra](lu_tricks.html)\n", 50 | " - [Overview](lu_tricks.html#overview)\n", 51 | " - [A Control Problem](lu_tricks.html#a-control-problem)\n", 52 | " - [Finite Horizon Theory](lu_tricks.html#finite-horizon-theory)\n", 53 | " - [The Infinite Horizon Limit](lu_tricks.html#the-infinite-horizon-limit)\n", 54 | " - [Undiscounted Problems](lu_tricks.html#undiscounted-problems)\n", 55 | " - [Implementation](lu_tricks.html#implementation)\n", 56 | " - [Exercises](lu_tricks.html#exercises)\n", 57 | "- [Classical Filtering With Linear Algebra](classical_filtering.html)\n", 58 | " - [Overview](classical_filtering.html#overview)\n", 59 | " - [Infinite Horizon Prediction and Filtering Problems](classical_filtering.html#infinite-horizon-prediction-and-filtering-problems)\n", 60 | " - [Finite Dimensional Prediction](classical_filtering.html#finite-dimensional-prediction)\n", 61 | " - [Combined Finite Dimensional Control and Prediction](classical_filtering.html#combined-finite-dimensional-control-and-prediction)\n", 62 | " - [Exercises](classical_filtering.html#exercises)" 63 | ] 64 | } 65 | ], 66 | "metadata": { 67 | "date": 1591310626.856452, 68 | "download_nb": 1, 69 | "download_nb_path": "https://julia.quantecon.org/", 70 | "filename": "index_grad.rst", 71 | "filename_with_path": "time_series_models/index_grad", 72 | "kernelspec": { 73 | "display_name": "Julia 1.4.2", 74 | "language": "julia", 75 | "name": "julia-1.4" 76 | }, 77 | "language_info": { 78 | "file_extension": ".jl", 79 | "mimetype": "application/julia", 80 | "name": "julia", 81 | "version": "1.4.2" 82 | }, 83 | "title": "Time Series Models" 84 | }, 85 | "nbformat": 4, 86 | "nbformat_minor": 2 87 | } 88 | -------------------------------------------------------------------------------- /Project.toml: -------------------------------------------------------------------------------- 1 | name = "quantecon-notebooks-julia" 2 | authors = ["arnavs "] 3 | version = "0.8.0" 4 | 5 | [deps] 6 | AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c" 7 | ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" 8 | Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97" 9 | BandedMatrices = "aae01518-5342-5314-be14-df237901396f" 10 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 11 | BlackBoxOptim = "a134a8b2-14d6-55f6-9291-3336d3ab0209" 12 | BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" 13 | CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" 14 | Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" 15 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 16 | DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" 17 | Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94" 18 | DiffEqOperators = "9fdde737-9c7f-55bf-ade8-46b3f136cc48" 19 | Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" 20 | Expectations = "2fe49d83-0758-5602-8f54-1f90ad0d522b" 21 | Expokit = "a1e7a1ef-7a5d-5822-a38c-be74e1bb89f4" 22 | ExponentialUtilities = "d4d017d3-3776-5f7e-afef-a10c40355c18" 23 | FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838" 24 | FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" 25 | FixedEffectModels = "9d5cd8c9-2029-5cab-9928-427838db53e3" 26 | FixedEffects = "c8885935-8500-56a7-9867-7708b20db0eb" 27 | Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" 28 | ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" 29 | GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a" 30 | GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" 31 | IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895" 32 | InstantiateFromURL = "43edad99-fa64-5e4f-9937-1c09a410b73f" 33 | Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" 34 | Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" 35 | IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153" 36 | JuMP = "4076af6c-e467-56ae-b986-b466b2749572" 37 | KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" 38 | Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7" 39 | KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" 40 | LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" 41 | LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" 42 | LeastSquaresOptim = "0fc2ff8b-aaa3-5acd-a817-1944a5e08891" 43 | LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" 44 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 45 | LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e" 46 | LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125" 47 | ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" 48 | NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd" 49 | NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" 50 | Optim = "429524aa-4258-5aef-a3af-852621145aeb" 51 | OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" 52 | Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" 53 | PkgTemplates = "14b8a8f1-9102-5b29-a752-f990bacb7fe1" 54 | Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 55 | Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" 56 | Preconditioners = "af69fa37-3177-5a40-98ee-561f696e4fcd" 57 | ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" 58 | QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" 59 | QuantEcon = "fcd29c91-0bd7-5a09-975d-7ac3f643a60c" 60 | Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1" 61 | RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" 62 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 63 | RegressionTables = "d519eb52-b820-54da-95a6-98e1306fdade" 64 | Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" 65 | Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" 66 | SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 67 | SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804" 68 | SparsityDetection = "684fba80-ace3-11e9-3d08-3bc7ed6f96df" 69 | StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" 70 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 71 | StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 72 | StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" 73 | StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" 74 | StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0" 75 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 76 | TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" 77 | VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a" 78 | Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" 79 | -------------------------------------------------------------------------------- /tools_and_techniques/index_undergrad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Tools and Techniques\n", 21 | "\n", 22 | "This section of the course contains foundational mathematical and statistical\n", 23 | "tools and techniques." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Linear Algebra](linear_algebra.html)\n", 33 | " - [Overview](linear_algebra.html#overview)\n", 34 | " - [Vectors](linear_algebra.html#vectors)\n", 35 | " - [Matrices](linear_algebra.html#matrices)\n", 36 | " - [Solving Systems of Equations](linear_algebra.html#solving-systems-of-equations)\n", 37 | " - [Eigenvalues and Eigenvectors](linear_algebra.html#eigenvalues-and-eigenvectors)\n", 38 | " - [Further Topics](linear_algebra.html#further-topics)\n", 39 | " - [Exercises](linear_algebra.html#exercises)\n", 40 | " - [Solutions](linear_algebra.html#solutions)\n", 41 | "- [LLN and CLT](lln_clt.html)\n", 42 | " - [Overview](lln_clt.html#overview)\n", 43 | " - [Relationships](lln_clt.html#relationships)\n", 44 | " - [LLN](lln_clt.html#lln)\n", 45 | " - [CLT](lln_clt.html#clt)\n", 46 | " - [Exercises](lln_clt.html#exercises)\n", 47 | " - [Solutions](lln_clt.html#solutions)\n", 48 | "- [Linear State Space Models](linear_models.html)\n", 49 | " - [Overview](linear_models.html#overview)\n", 50 | " - [The Linear State Space Model](linear_models.html#the-linear-state-space-model)\n", 51 | " - [Distributions and Moments](linear_models.html#distributions-and-moments)\n", 52 | " - [Stationarity and Ergodicity](linear_models.html#stationarity-and-ergodicity)\n", 53 | " - [Noisy Observations](linear_models.html#noisy-observations)\n", 54 | " - [Prediction](linear_models.html#prediction)\n", 55 | " - [Code](linear_models.html#code)\n", 56 | " - [Exercises](linear_models.html#exercises)\n", 57 | " - [Solutions](linear_models.html#solutions)\n", 58 | "- [Finite Markov Chains](finite_markov.html)\n", 59 | " - [Overview](finite_markov.html#overview)\n", 60 | " - [Definitions](finite_markov.html#definitions)\n", 61 | " - [Simulation](finite_markov.html#simulation)\n", 62 | " - [Marginal Distributions](finite_markov.html#marginal-distributions)\n", 63 | " - [Irreducibility and Aperiodicity](finite_markov.html#irreducibility-and-aperiodicity)\n", 64 | " - [Stationary Distributions](finite_markov.html#stationary-distributions)\n", 65 | " - [Ergodicity](finite_markov.html#ergodicity)\n", 66 | " - [Computing Expectations](finite_markov.html#computing-expectations)\n", 67 | " - [Exercises](finite_markov.html#exercises)\n", 68 | " - [Solutions](finite_markov.html#solutions)\n", 69 | "- [A First Look at the Kalman Filter](kalman.html)\n", 70 | " - [Overview](kalman.html#overview)\n", 71 | " - [The Basic Idea](kalman.html#the-basic-idea)\n", 72 | " - [Convergence](kalman.html#convergence)\n", 73 | " - [Implementation](kalman.html#implementation)\n", 74 | " - [Exercises](kalman.html#exercises)\n", 75 | " - [Solutions](kalman.html#solutions)" 76 | ] 77 | } 78 | ], 79 | "metadata": { 80 | "date": 1591310627.6207023, 81 | "download_nb": 1, 82 | "download_nb_path": "https://julia.quantecon.org/", 83 | "filename": "index_undergrad.rst", 84 | "filename_with_path": "tools_and_techniques/index_undergrad", 85 | "kernelspec": { 86 | "display_name": "Julia 1.4.2", 87 | "language": "julia", 88 | "name": "julia-1.4" 89 | }, 90 | "language_info": { 91 | "file_extension": ".jl", 92 | "mimetype": "application/julia", 93 | "name": "julia", 94 | "version": "1.4.2" 95 | }, 96 | "title": "Tools and Techniques" 97 | }, 98 | "nbformat": 4, 99 | "nbformat_minor": 2 100 | } 101 | -------------------------------------------------------------------------------- /index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# Quantitative Economics with Julia\n", 16 | "\n", 17 | "
\n", 18 | "

Quantitative Economics with Python

\n", 19 | "
\n", 20 | "
\n", 21 | "
\n", 22 | "

This website presents a set of lectures on quantitative economic modeling, designed and written by Jesse Perla, Thomas J. Sargent and John Stachurski. The language instruction is Julia.

\n", 23 | "

This is one of a series of lectures by QuantEcon.

\n", 24 | "

Last compiled: (view commits)

\n", 25 | "
\n", 26 | " \n", 33 | "
\n", 34 | " \n", 38 | "
\n", 39 | "
\n", 40 | "

Other ways to access the lectures

\n", 41 | " \n", 57 | "
\n", 58 | "
\n", 59 | "

Open source lectures

\n", 60 | " \n", 69 | "
" 70 | ] 71 | } 72 | ], 73 | "metadata": { 74 | "date": 1591310621.906702, 75 | "download_nb": 1, 76 | "download_nb_path": "https://julia.quantecon.org/", 77 | "filename": "index.rst", 78 | "filename_with_path": "index", 79 | "kernelspec": { 80 | "display_name": "Julia 1.4.2", 81 | "language": "julia", 82 | "name": "julia-1.4" 83 | }, 84 | "language_info": { 85 | "file_extension": ".jl", 86 | "mimetype": "application/julia", 87 | "name": "julia", 88 | "version": "1.4.2" 89 | }, 90 | "title": "Quantitative Economics with Julia" 91 | }, 92 | "nbformat": 4, 93 | "nbformat_minor": 2 94 | } 95 | -------------------------------------------------------------------------------- /troubleshooting.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Troubleshooting" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "## Contents\n", 28 | "\n", 29 | "- [Troubleshooting](#Troubleshooting) \n", 30 | " - [Fixing Your Local Environment](#Fixing-Your-Local-Environment) \n", 31 | " - [Upgrading Julia](#Upgrading-Julia) \n", 32 | " - [Fixing Atom](#Fixing-Atom) \n", 33 | " - [Resetting a JupyterHub Lecture Set](#Resetting-a-JupyterHub-Lecture-Set) \n", 34 | " - [Reporting an Issue](#Reporting-an-Issue) " 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "This troubleshooting page is to help ensure you software environment is setup correctly\n", 42 | "to run this lecture set locally on your machine." 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "## Fixing Your Local Environment\n", 50 | "\n", 51 | "To set up a standard desktop environment, you can run the instructions in our [local setup lecture](https://julia.quantecon.org/getting_started_julia/getting_started.html#Desktop-Installation-of-Julia-and-Jupyter).\n", 52 | "\n", 53 | "If you already have, make sure to try deleting your `.julia` directory (the “user depot,” where packages are stored) and re-running the lectures (after running `] add InstantiateFromURL`!).\n", 54 | "\n", 55 | "You can find this directory by running `DEPOT_PATH[1]` in a Julia REPL." 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "metadata": {}, 61 | "source": [ 62 | "## Upgrading Julia\n", 63 | "\n", 64 | "See the [lecture section](more_julia/tools_editors.html#upgrading-julia) on getting Atom and Jupyter working with a new version." 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "## Fixing Atom\n", 72 | "\n", 73 | "See the [lecture section](more_julia/tools_editors.html#atom-troubleshooting) on troubleshooting Atom." 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "## Resetting a JupyterHub Lecture Set\n", 81 | "\n", 82 | "The lectures are delivered to JupyterHubs using `nbgitpuller`.\n", 83 | "\n", 84 | "To reset a single notebook, simply delete it and click the relevant link again.\n", 85 | "\n", 86 | "To reset your whole lecture set, run `rm -rf quantecon-notebooks-julia` in the Terminal (after `cd`-ing to where they’re downloaded, which is usually the root) and click any lecture’s link again." 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "## Reporting an Issue\n", 94 | "\n", 95 | "One way to give feedback is to raise an issue through our [issue tracker](https://github.com/QuantEcon/lecture-source-py/issues).\n", 96 | "\n", 97 | "Please be as specific as possible. Tell us where the problem is and as much\n", 98 | "detail about your local set up as you can provide.\n", 99 | "\n", 100 | "Another feedback option is to use our [discourse forum](https://discourse.quantecon.org/).\n", 101 | "\n", 102 | "Finally, you can provide direct feedback to [contact@quantecon.org](mailto:contact@quantecon.org)" 103 | ] 104 | } 105 | ], 106 | "metadata": { 107 | "date": 1591310629.8242235, 108 | "download_nb": 1, 109 | "download_nb_path": "https://julia.quantecon.org/", 110 | "filename": "troubleshooting.rst", 111 | "filename_with_path": "troubleshooting", 112 | "kernelspec": { 113 | "display_name": "Julia 1.4.2", 114 | "language": "julia", 115 | "name": "julia-1.4" 116 | }, 117 | "language_info": { 118 | "file_extension": ".jl", 119 | "mimetype": "application/julia", 120 | "name": "julia", 121 | "version": "1.4.2" 122 | }, 123 | "title": "Troubleshooting" 124 | }, 125 | "nbformat": 4, 126 | "nbformat_minor": 2 127 | } 128 | -------------------------------------------------------------------------------- /index_undergrad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

\"Powered

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "# Table of Contents (Undergraduate course)\n", 15 | "\n", 16 | "\n", 21 | "\n", 22 | "- [About these Lectures](about_lectures.html)\n", 23 | "- [Getting Started with Julia](getting_started_julia/index.html)\n", 24 | " - [Setting up Your Julia Environment](getting_started_julia/getting_started.html)\n", 25 | " - [Interacting with Julia](getting_started_julia/julia_environment.html)\n", 26 | " - [Introductory Examples](getting_started_julia/julia_by_example.html)\n", 27 | " - [Julia Essentials](getting_started_julia/julia_essentials.html)\n", 28 | " - [Arrays, Tuples, Ranges, and Other Fundamental Types](getting_started_julia/fundamental_types.html)\n", 29 | " - [Introduction to Types and Generic Programming](getting_started_julia/introduction_to_types.html)\n", 30 | "- [Packages and Software Engineering in Julia](more_julia/index.html)\n", 31 | " - [Generic Programming](more_julia/generic_programming.html)\n", 32 | " - [General Purpose Packages](more_julia/general_packages.html)\n", 33 | " - [Data and Statistics Packages](more_julia/data_statistical_packages.html)\n", 34 | " - [Solvers, Optimizers, and Automatic Differentiation](more_julia/optimization_solver_packages.html)\n", 35 | " - [Julia Tools and Editors](more_julia/tools_editors.html)\n", 36 | " - [Git, GitHub, and Version Control](more_julia/version_control.html)\n", 37 | " - [Packages, Testing, and Continuous Integration](more_julia/testing.html)\n", 38 | " - [The Need for Speed](more_julia/need_for_speed.html)\n", 39 | "- [Tools and Techniques](tools_and_techniques/index_undergrad.html)\n", 40 | " - [Linear Algebra](tools_and_techniques/linear_algebra.html)\n", 41 | " - [LLN and CLT](tools_and_techniques/lln_clt.html)\n", 42 | " - [Linear State Space Models](tools_and_techniques/linear_models.html)\n", 43 | " - [Finite Markov Chains](tools_and_techniques/finite_markov.html)\n", 44 | " - [A First Look at the Kalman Filter](tools_and_techniques/kalman.html)\n", 45 | "- [Dynamic Programming](dynamic_programming/index_undergrad.html)\n", 46 | " - [Shortest Paths](dynamic_programming/short_path.html)\n", 47 | " - [Job Search I: The McCall Search Model](dynamic_programming/mccall_model.html)\n", 48 | " - [Job Search II: Search and Separation](dynamic_programming/mccall_model_with_separation.html)\n", 49 | " - [Optimal Savings I: The Permanent Income Model](dynamic_programming/perm_income.html)\n", 50 | " - [Optimal Savings II: LQ Techniques](dynamic_programming/perm_income_cons.html)\n", 51 | " - [Consumption and Tax Smoothing with Complete and Incomplete Markets](dynamic_programming/smoothing.html)\n", 52 | "- [Multiple Agent Models](multi_agent_models/index_undergrad.html)\n", 53 | " - [Schelling’s Segregation Model](multi_agent_models/schelling.html)\n", 54 | " - [A Lake Model of Employment and Unemployment](multi_agent_models/lake_model.html)\n", 55 | " - [Rational Expectations Equilibrium](multi_agent_models/rational_expectations.html)\n", 56 | " - [Markov Perfect Equilibrium](multi_agent_models/markov_perf.html)\n", 57 | " - [Asset Pricing I: Finite State Models](multi_agent_models/markov_asset.html)\n", 58 | "- [References](zreferences.html)\n", 59 | "\n", 60 | "\n", 61 | "" 62 | ] 63 | } 64 | ], 65 | "metadata": { 66 | "date": 1591310622.3554873, 67 | "download_nb": 1, 68 | "download_nb_path": "https://julia.quantecon.org/", 69 | "filename": "index_undergrad.rst", 70 | "filename_with_path": "index_undergrad", 71 | "kernelspec": { 72 | "display_name": "Julia 1.4.2", 73 | "language": "julia", 74 | "name": "julia-1.4" 75 | }, 76 | "language_info": { 77 | "file_extension": ".jl", 78 | "mimetype": "application/julia", 79 | "name": "julia", 80 | "version": "1.4.2" 81 | }, 82 | "title": "Table of Contents (Undergraduate course)" 83 | }, 84 | "nbformat": 4, 85 | "nbformat_minor": 2 86 | } 87 | -------------------------------------------------------------------------------- /dynamic_programming/index_undergrad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Dynamic Programming\n", 21 | "\n", 22 | "This section of the course contains foundational models for dynamic economic\n", 23 | "modeling. Most are single agent problems that take the activities of other\n", 24 | "agents as given. Later we will look at full equilibrium problems." 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "## Lectures\n", 32 | "\n", 33 | "- [Shortest Paths](short_path.html)\n", 34 | " - [Overview](short_path.html#overview)\n", 35 | " - [Outline of the Problem](short_path.html#outline-of-the-problem)\n", 36 | " - [Finding Least-Cost Paths](short_path.html#finding-least-cost-paths)\n", 37 | " - [Solving for $ J $](short_path.html#solving-for-j)\n", 38 | " - [Exercises](short_path.html#exercises)\n", 39 | " - [Solutions](short_path.html#solutions)\n", 40 | "- [Job Search I: The McCall Search Model](mccall_model.html)\n", 41 | " - [Overview](mccall_model.html#overview)\n", 42 | " - [The McCall Model](mccall_model.html#the-mccall-model)\n", 43 | " - [Computing the Optimal Policy: Take 1](mccall_model.html#computing-the-optimal-policy-take-1)\n", 44 | " - [Computing the Optimal Policy: Take 2](mccall_model.html#computing-the-optimal-policy-take-2)\n", 45 | " - [Exercises](mccall_model.html#exercises)\n", 46 | " - [Solutions](mccall_model.html#solutions)\n", 47 | "- [Job Search II: Search and Separation](mccall_model_with_separation.html)\n", 48 | " - [Overview](mccall_model_with_separation.html#overview)\n", 49 | " - [The Model](mccall_model_with_separation.html#the-model)\n", 50 | " - [Solving the Model using Dynamic Programming](mccall_model_with_separation.html#solving-the-model-using-dynamic-programming)\n", 51 | " - [Implementation](mccall_model_with_separation.html#implementation)\n", 52 | " - [The Reservation Wage](mccall_model_with_separation.html#the-reservation-wage)\n", 53 | " - [Exercises](mccall_model_with_separation.html#exercises)\n", 54 | " - [Solutions](mccall_model_with_separation.html#solutions)\n", 55 | "- [Optimal Savings I: The Permanent Income Model](perm_income.html)\n", 56 | " - [Overview](perm_income.html#overview)\n", 57 | " - [The Savings Problem](perm_income.html#the-savings-problem)\n", 58 | " - [Alternative Representations](perm_income.html#alternative-representations)\n", 59 | " - [Two Classic Examples](perm_income.html#two-classic-examples)\n", 60 | " - [Further Reading](perm_income.html#further-reading)\n", 61 | " - [Appendix: the Euler Equation](perm_income.html#appendix-the-euler-equation)\n", 62 | "- [Optimal Savings II: LQ Techniques](perm_income_cons.html)\n", 63 | " - [Overview](perm_income_cons.html#overview)\n", 64 | " - [Introduction](perm_income_cons.html#introduction)\n", 65 | " - [The LQ Approach](perm_income_cons.html#the-lq-approach)\n", 66 | " - [Implementation](perm_income_cons.html#implementation)\n", 67 | " - [Two Example Economies](perm_income_cons.html#two-example-economies)\n", 68 | "- [Consumption and Tax Smoothing with Complete and Incomplete Markets](smoothing.html)\n", 69 | " - [Overview](smoothing.html#overview)\n", 70 | " - [Background](smoothing.html#background)\n", 71 | " - [Model 1 (Complete Markets)](smoothing.html#model-1-complete-markets)\n", 72 | " - [Model 2 (One-Period Risk Free Debt Only)](smoothing.html#model-2-one-period-risk-free-debt-only)\n", 73 | " - [Example: Tax Smoothing with Complete Markets](smoothing.html#example-tax-smoothing-with-complete-markets)\n", 74 | " - [Linear State Space Version of Complete Markets Model](smoothing.html#linear-state-space-version-of-complete-markets-model)" 75 | ] 76 | } 77 | ], 78 | "metadata": { 79 | "date": 1591310615.408813, 80 | "download_nb": 1, 81 | "download_nb_path": "https://julia.quantecon.org/", 82 | "filename": "index_undergrad.rst", 83 | "filename_with_path": "dynamic_programming/index_undergrad", 84 | "kernelspec": { 85 | "display_name": "Julia 1.4.2", 86 | "language": "julia", 87 | "name": "julia-1.4" 88 | }, 89 | "language_info": { 90 | "file_extension": ".jl", 91 | "mimetype": "application/julia", 92 | "name": "julia", 93 | "version": "1.4.2" 94 | }, 95 | "title": "Dynamic Programming" 96 | }, 97 | "nbformat": 4, 98 | "nbformat_minor": 2 99 | } 100 | -------------------------------------------------------------------------------- /getting_started_julia/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Getting Started with Julia\n", 21 | "\n", 22 | "This first part of the course provides a relatively fast-paced introduction to enough of the Julia programming language to understand the lectures." 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "## Lectures\n", 30 | "\n", 31 | "- [Setting up Your Julia Environment](getting_started.html)\n", 32 | " - [Overview](getting_started.html#overview)\n", 33 | " - [A Note on Jupyter](getting_started.html#a-note-on-jupyter)\n", 34 | " - [Desktop Installation of Julia and Jupyter](getting_started.html#desktop-installation-of-julia-and-jupyter)\n", 35 | " - [Using Julia on the Web](getting_started.html#using-julia-on-the-web)\n", 36 | " - [Installing Packages](getting_started.html#installing-packages)\n", 37 | "- [Interacting with Julia](julia_environment.html)\n", 38 | " - [Overview](julia_environment.html#overview)\n", 39 | " - [Using Jupyter](julia_environment.html#using-jupyter)\n", 40 | " - [Using the REPL](julia_environment.html#using-the-repl)\n", 41 | " - [(Optional) Adding Jupyter to the Path](julia_environment.html#optional-adding-jupyter-to-the-path)\n", 42 | "- [Introductory Examples](julia_by_example.html)\n", 43 | " - [Overview](julia_by_example.html#overview)\n", 44 | " - [Example: Plotting a White Noise Process](julia_by_example.html#example-plotting-a-white-noise-process)\n", 45 | " - [Example: Variations on Fixed Points](julia_by_example.html#example-variations-on-fixed-points)\n", 46 | " - [Exercises](julia_by_example.html#exercises)\n", 47 | " - [Solutions](julia_by_example.html#solutions)\n", 48 | "- [Julia Essentials](julia_essentials.html)\n", 49 | " - [Overview](julia_essentials.html#overview)\n", 50 | " - [Common Data Types](julia_essentials.html#common-data-types)\n", 51 | " - [Iterating](julia_essentials.html#iterating)\n", 52 | " - [Comparisons and Logical Operators](julia_essentials.html#comparisons-and-logical-operators)\n", 53 | " - [User-Defined Functions](julia_essentials.html#user-defined-functions)\n", 54 | " - [Broadcasting](julia_essentials.html#broadcasting)\n", 55 | " - [Scoping and Closures](julia_essentials.html#scoping-and-closures)\n", 56 | " - [Exercises](julia_essentials.html#exercises)\n", 57 | " - [Solutions](julia_essentials.html#solutions)\n", 58 | "- [Arrays, Tuples, Ranges, and Other Fundamental Types](fundamental_types.html)\n", 59 | " - [Overview](fundamental_types.html#overview)\n", 60 | " - [Array Basics](fundamental_types.html#array-basics)\n", 61 | " - [Operations on Arrays](fundamental_types.html#operations-on-arrays)\n", 62 | " - [Ranges](fundamental_types.html#ranges)\n", 63 | " - [Tuples and Named Tuples](fundamental_types.html#tuples-and-named-tuples)\n", 64 | " - [Nothing, Missing, and Unions](fundamental_types.html#nothing-missing-and-unions)\n", 65 | " - [Exercises](fundamental_types.html#exercises)\n", 66 | " - [Solutions](fundamental_types.html#solutions)\n", 67 | "- [Introduction to Types and Generic Programming](introduction_to_types.html)\n", 68 | " - [Overview](introduction_to_types.html#overview)\n", 69 | " - [Finding and Interpreting Types](introduction_to_types.html#finding-and-interpreting-types)\n", 70 | " - [The Type Hierarchy](introduction_to_types.html#the-type-hierarchy)\n", 71 | " - [Deducing and Declaring Types](introduction_to_types.html#deducing-and-declaring-types)\n", 72 | " - [Creating New Types](introduction_to_types.html#creating-new-types)\n", 73 | " - [Introduction to Multiple Dispatch](introduction_to_types.html#introduction-to-multiple-dispatch)\n", 74 | " - [Exercises](introduction_to_types.html#exercises)" 75 | ] 76 | } 77 | ], 78 | "metadata": { 79 | "date": 1591310619.9610262, 80 | "download_nb": 1, 81 | "download_nb_path": "https://julia.quantecon.org/", 82 | "filename": "index.rst", 83 | "filename_with_path": "getting_started_julia/index", 84 | "kernelspec": { 85 | "display_name": "Julia 1.4.2", 86 | "language": "julia", 87 | "name": "julia-1.4" 88 | }, 89 | "language_info": { 90 | "file_extension": ".jl", 91 | "mimetype": "application/julia", 92 | "name": "julia", 93 | "version": "1.4.2" 94 | }, 95 | "title": "Getting Started with Julia" 96 | }, 97 | "nbformat": 4, 98 | "nbformat_minor": 2 99 | } 100 | -------------------------------------------------------------------------------- /tools_and_techniques/index_grad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Tools and Techniques\n", 21 | "\n", 22 | "This section of the course contains foundational mathematical and statistical\n", 23 | "tools and techniques." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Linear Algebra](linear_algebra.html)\n", 33 | " - [Overview](linear_algebra.html#overview)\n", 34 | " - [Vectors](linear_algebra.html#vectors)\n", 35 | " - [Matrices](linear_algebra.html#matrices)\n", 36 | " - [Solving Systems of Equations](linear_algebra.html#solving-systems-of-equations)\n", 37 | " - [Eigenvalues and Eigenvectors](linear_algebra.html#eigenvalues-and-eigenvectors)\n", 38 | " - [Further Topics](linear_algebra.html#further-topics)\n", 39 | " - [Exercises](linear_algebra.html#exercises)\n", 40 | " - [Solutions](linear_algebra.html#solutions)\n", 41 | "- [Orthogonal Projections and Their Applications](orth_proj.html)\n", 42 | " - [Overview](orth_proj.html#overview)\n", 43 | " - [Key Definitions](orth_proj.html#key-definitions)\n", 44 | " - [The Orthogonal Projection Theorem](orth_proj.html#the-orthogonal-projection-theorem)\n", 45 | " - [Orthonormal Basis](orth_proj.html#orthonormal-basis)\n", 46 | " - [Projection Using Matrix Algebra](orth_proj.html#projection-using-matrix-algebra)\n", 47 | " - [Least Squares Regression](orth_proj.html#least-squares-regression)\n", 48 | " - [Orthogonalization and Decomposition](orth_proj.html#orthogonalization-and-decomposition)\n", 49 | " - [Exercises](orth_proj.html#exercises)\n", 50 | " - [Solutions](orth_proj.html#solutions)\n", 51 | "- [LLN and CLT](lln_clt.html)\n", 52 | " - [Overview](lln_clt.html#overview)\n", 53 | " - [Relationships](lln_clt.html#relationships)\n", 54 | " - [LLN](lln_clt.html#lln)\n", 55 | " - [CLT](lln_clt.html#clt)\n", 56 | " - [Exercises](lln_clt.html#exercises)\n", 57 | " - [Solutions](lln_clt.html#solutions)\n", 58 | "- [Linear State Space Models](linear_models.html)\n", 59 | " - [Overview](linear_models.html#overview)\n", 60 | " - [The Linear State Space Model](linear_models.html#the-linear-state-space-model)\n", 61 | " - [Distributions and Moments](linear_models.html#distributions-and-moments)\n", 62 | " - [Stationarity and Ergodicity](linear_models.html#stationarity-and-ergodicity)\n", 63 | " - [Noisy Observations](linear_models.html#noisy-observations)\n", 64 | " - [Prediction](linear_models.html#prediction)\n", 65 | " - [Code](linear_models.html#code)\n", 66 | " - [Exercises](linear_models.html#exercises)\n", 67 | " - [Solutions](linear_models.html#solutions)\n", 68 | "- [Finite Markov Chains](finite_markov.html)\n", 69 | " - [Overview](finite_markov.html#overview)\n", 70 | " - [Definitions](finite_markov.html#definitions)\n", 71 | " - [Simulation](finite_markov.html#simulation)\n", 72 | " - [Marginal Distributions](finite_markov.html#marginal-distributions)\n", 73 | " - [Irreducibility and Aperiodicity](finite_markov.html#irreducibility-and-aperiodicity)\n", 74 | " - [Stationary Distributions](finite_markov.html#stationary-distributions)\n", 75 | " - [Ergodicity](finite_markov.html#ergodicity)\n", 76 | " - [Computing Expectations](finite_markov.html#computing-expectations)\n", 77 | " - [Exercises](finite_markov.html#exercises)\n", 78 | " - [Solutions](finite_markov.html#solutions)\n", 79 | "- [Continuous State Markov Chains](stationary_densities.html)\n", 80 | " - [Overview](stationary_densities.html#overview)\n", 81 | " - [The Density Case](stationary_densities.html#the-density-case)\n", 82 | " - [Beyond Densities](stationary_densities.html#beyond-densities)\n", 83 | " - [Stability](stationary_densities.html#stability)\n", 84 | " - [Exercises](stationary_densities.html#exercises)\n", 85 | " - [Solutions](stationary_densities.html#solutions)\n", 86 | " - [Appendix](stationary_densities.html#appendix)\n", 87 | "- [A First Look at the Kalman Filter](kalman.html)\n", 88 | " - [Overview](kalman.html#overview)\n", 89 | " - [The Basic Idea](kalman.html#the-basic-idea)\n", 90 | " - [Convergence](kalman.html#convergence)\n", 91 | " - [Implementation](kalman.html#implementation)\n", 92 | " - [Exercises](kalman.html#exercises)\n", 93 | " - [Solutions](kalman.html#solutions)" 94 | ] 95 | } 96 | ], 97 | "metadata": { 98 | "date": 1591310627.5938811, 99 | "download_nb": 1, 100 | "download_nb_path": "https://julia.quantecon.org/", 101 | "filename": "index_grad.rst", 102 | "filename_with_path": "tools_and_techniques/index_grad", 103 | "kernelspec": { 104 | "display_name": "Julia 1.4.2", 105 | "language": "julia", 106 | "name": "julia-1.4" 107 | }, 108 | "language_info": { 109 | "file_extension": ".jl", 110 | "mimetype": "application/julia", 111 | "name": "julia", 112 | "version": "1.4.2" 113 | }, 114 | "title": "Tools and Techniques" 115 | }, 116 | "nbformat": 4, 117 | "nbformat_minor": 2 118 | } 119 | -------------------------------------------------------------------------------- /index_postgrad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "

\"Powered

" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "# Table of Contents (Graduate course)\n", 15 | "\n", 16 | "\n", 21 | "\n", 22 | "- [About these Lectures](about_lectures.html)\n", 23 | "- [Getting Started with Julia](getting_started_julia/index.html)\n", 24 | " - [Setting up Your Julia Environment](getting_started_julia/getting_started.html)\n", 25 | " - [Interacting with Julia](getting_started_julia/julia_environment.html)\n", 26 | " - [Introductory Examples](getting_started_julia/julia_by_example.html)\n", 27 | " - [Julia Essentials](getting_started_julia/julia_essentials.html)\n", 28 | " - [Arrays, Tuples, Ranges, and Other Fundamental Types](getting_started_julia/fundamental_types.html)\n", 29 | " - [Introduction to Types and Generic Programming](getting_started_julia/introduction_to_types.html)\n", 30 | "- [Packages and Software Engineering in Julia](more_julia/index.html)\n", 31 | " - [Generic Programming](more_julia/generic_programming.html)\n", 32 | " - [General Purpose Packages](more_julia/general_packages.html)\n", 33 | " - [Data and Statistics Packages](more_julia/data_statistical_packages.html)\n", 34 | " - [Solvers, Optimizers, and Automatic Differentiation](more_julia/optimization_solver_packages.html)\n", 35 | " - [Julia Tools and Editors](more_julia/tools_editors.html)\n", 36 | " - [Git, GitHub, and Version Control](more_julia/version_control.html)\n", 37 | " - [Packages, Testing, and Continuous Integration](more_julia/testing.html)\n", 38 | " - [The Need for Speed](more_julia/need_for_speed.html)\n", 39 | "- [Tools and Techniques](tools_and_techniques/index_grad.html)\n", 40 | " - [Linear Algebra](tools_and_techniques/linear_algebra.html)\n", 41 | " - [Orthogonal Projections and Their Applications](tools_and_techniques/orth_proj.html)\n", 42 | " - [LLN and CLT](tools_and_techniques/lln_clt.html)\n", 43 | " - [Linear State Space Models](tools_and_techniques/linear_models.html)\n", 44 | " - [Finite Markov Chains](tools_and_techniques/finite_markov.html)\n", 45 | " - [Continuous State Markov Chains](tools_and_techniques/stationary_densities.html)\n", 46 | " - [A First Look at the Kalman Filter](tools_and_techniques/kalman.html)\n", 47 | "- [Dynamic Programming](dynamic_programming/index_grad.html)\n", 48 | " - [Job Search I: The McCall Search Model](dynamic_programming/mccall_model.html)\n", 49 | " - [Job Search II: Search and Separation](dynamic_programming/mccall_model_with_separation.html)\n", 50 | " - [A Problem that Stumped Milton Friedman](dynamic_programming/wald_friedman.html)\n", 51 | " - [Job Search III: Search with Learning](dynamic_programming/odu.html)\n", 52 | " - [Job Search IV: Modeling Career Choice](dynamic_programming/career.html)\n", 53 | " - [Job Search V: On-the-Job Search](dynamic_programming/jv.html)\n", 54 | " - [Optimal Growth I: The Stochastic Optimal Growth Model](dynamic_programming/optgrowth.html)\n", 55 | " - [Optimal Growth II: Time Iteration](dynamic_programming/coleman_policy_iter.html)\n", 56 | " - [Optimal Growth III: The Endogenous Grid Method](dynamic_programming/egm_policy_iter.html)\n", 57 | " - [LQ Dynamic Programming Problems](dynamic_programming/lqcontrol.html)\n", 58 | " - [Optimal Savings III: Occasionally Binding Constraints](dynamic_programming/ifp.html)\n", 59 | " - [Robustness](dynamic_programming/robustness.html)\n", 60 | " - [Discrete State Dynamic Programming](dynamic_programming/discrete_dp.html)\n", 61 | "- [Multiple Agent Models](multi_agent_models/index_grad.html)\n", 62 | " - [Asset Pricing II: The Lucas Asset Pricing Model](multi_agent_models/lucas_model.html)\n", 63 | " - [Uncertainty Traps](multi_agent_models/uncertainty_traps.html)\n", 64 | " - [The Aiyagari Model](multi_agent_models/aiyagari.html)\n", 65 | " - [Default Risk and Income Fluctuations](multi_agent_models/arellano.html)\n", 66 | " - [Globalization and Cycles](multi_agent_models/matsuyama.html)\n", 67 | "- [Time Series Models](time_series_models/index_grad.html)\n", 68 | " - [Covariance Stationary Processes](time_series_models/arma.html)\n", 69 | " - [Estimation of Spectra](time_series_models/estspec.html)\n", 70 | " - [Additive Functionals](time_series_models/additive_functionals.html)\n", 71 | " - [Multiplicative Functionals](time_series_models/multiplicative_functionals.html)\n", 72 | " - [Classical Control with Linear Algebra](time_series_models/lu_tricks.html)\n", 73 | " - [Classical Filtering With Linear Algebra](time_series_models/classical_filtering.html)\n", 74 | "- [References](zreferences.html)\n", 75 | "\n", 76 | "\n", 77 | "" 78 | ] 79 | } 80 | ], 81 | "metadata": { 82 | "date": 1591310621.9968948, 83 | "download_nb": 1, 84 | "download_nb_path": "https://julia.quantecon.org/", 85 | "filename": "index_postgrad.rst", 86 | "filename_with_path": "index_postgrad", 87 | "kernelspec": { 88 | "display_name": "Julia 1.4.2", 89 | "language": "julia", 90 | "name": "julia-1.4" 91 | }, 92 | "language_info": { 93 | "file_extension": ".jl", 94 | "mimetype": "application/julia", 95 | "name": "julia", 96 | "version": "1.4.2" 97 | }, 98 | "title": "Table of Contents (Graduate course)" 99 | }, 100 | "nbformat": 4, 101 | "nbformat_minor": 2 102 | } 103 | -------------------------------------------------------------------------------- /multi_agent_models/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Multiple Agent Models\n", 21 | "\n", 22 | "These lectures look at important economic models that also illustrate common\n", 23 | "equilibrium concepts." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Schelling’s Segregation Model](schelling.html)\n", 33 | " - [Overview](schelling.html#overview)\n", 34 | " - [The Model](schelling.html#the-model)\n", 35 | " - [Results](schelling.html#results)\n", 36 | " - [Exercises](schelling.html#exercises)\n", 37 | " - [Solutions](schelling.html#solutions)\n", 38 | "- [A Lake Model of Employment and Unemployment](lake_model.html)\n", 39 | " - [Overview](lake_model.html#overview)\n", 40 | " - [The Model](lake_model.html#the-model)\n", 41 | " - [Implementation](lake_model.html#implementation)\n", 42 | " - [Dynamics of an Individual Worker](lake_model.html#dynamics-of-an-individual-worker)\n", 43 | " - [Endogenous Job Finding Rate](lake_model.html#endogenous-job-finding-rate)\n", 44 | " - [Exercises](lake_model.html#exercises)\n", 45 | " - [Solutions](lake_model.html#solutions)\n", 46 | "- [Rational Expectations Equilibrium](rational_expectations.html)\n", 47 | " - [Overview](rational_expectations.html#overview)\n", 48 | " - [Defining Rational Expectations Equilibrium](rational_expectations.html#defining-rational-expectations-equilibrium)\n", 49 | " - [Computation of an Equilibrium](rational_expectations.html#computation-of-an-equilibrium)\n", 50 | " - [Exercises](rational_expectations.html#exercises)\n", 51 | " - [Solutions](rational_expectations.html#solutions)\n", 52 | "- [Markov Perfect Equilibrium](markov_perf.html)\n", 53 | " - [Overview](markov_perf.html#overview)\n", 54 | " - [Background](markov_perf.html#background)\n", 55 | " - [Linear Markov perfect equilibria](markov_perf.html#linear-markov-perfect-equilibria)\n", 56 | " - [Application](markov_perf.html#application)\n", 57 | " - [Exercises](markov_perf.html#exercises)\n", 58 | " - [Solutions](markov_perf.html#solutions)\n", 59 | "- [Asset Pricing I: Finite State Models](markov_asset.html)\n", 60 | " - [Overview](markov_asset.html#overview)\n", 61 | " - [Pricing Models](markov_asset.html#pricing-models)\n", 62 | " - [Prices in the Risk Neutral Case](markov_asset.html#prices-in-the-risk-neutral-case)\n", 63 | " - [Asset Prices under Risk Aversion](markov_asset.html#asset-prices-under-risk-aversion)\n", 64 | " - [Exercises](markov_asset.html#exercises)\n", 65 | " - [Solutions](markov_asset.html#solutions)\n", 66 | "- [Asset Pricing II: The Lucas Asset Pricing Model](lucas_model.html)\n", 67 | " - [Overview](lucas_model.html#overview)\n", 68 | " - [The Lucas Model](lucas_model.html#the-lucas-model)\n", 69 | " - [Exercises](lucas_model.html#exercises)\n", 70 | " - [Solutions](lucas_model.html#solutions)\n", 71 | "- [Asset Pricing III: Incomplete Markets](harrison_kreps.html)\n", 72 | " - [Overview](harrison_kreps.html#overview)\n", 73 | " - [Structure of the Model](harrison_kreps.html#structure-of-the-model)\n", 74 | " - [Solving the Model](harrison_kreps.html#solving-the-model)\n", 75 | " - [Exercises](harrison_kreps.html#exercises)\n", 76 | " - [Solutions](harrison_kreps.html#solutions)\n", 77 | "- [Uncertainty Traps](uncertainty_traps.html)\n", 78 | " - [Overview](uncertainty_traps.html#overview)\n", 79 | " - [The Model](uncertainty_traps.html#the-model)\n", 80 | " - [Implementation](uncertainty_traps.html#implementation)\n", 81 | " - [Results](uncertainty_traps.html#results)\n", 82 | " - [Exercises](uncertainty_traps.html#exercises)\n", 83 | " - [Solutions](uncertainty_traps.html#solutions)\n", 84 | " - [Exercise 2](uncertainty_traps.html#id6)\n", 85 | "- [The Aiyagari Model](aiyagari.html)\n", 86 | " - [Overview](aiyagari.html#overview)\n", 87 | " - [The Economy](aiyagari.html#the-economy)\n", 88 | " - [Firms](aiyagari.html#firms)\n", 89 | " - [Code](aiyagari.html#code)\n", 90 | "- [Default Risk and Income Fluctuations](arellano.html)\n", 91 | " - [Overview](arellano.html#overview)\n", 92 | " - [Structure](arellano.html#structure)\n", 93 | " - [Equilibrium](arellano.html#equilibrium)\n", 94 | " - [Computation](arellano.html#computation)\n", 95 | " - [Results](arellano.html#results)\n", 96 | " - [Exercises](arellano.html#exercises)\n", 97 | " - [Solutions](arellano.html#solutions)\n", 98 | "- [Globalization and Cycles](matsuyama.html)\n", 99 | " - [Overview](matsuyama.html#overview)\n", 100 | " - [Key Ideas](matsuyama.html#key-ideas)\n", 101 | " - [Model](matsuyama.html#model)\n", 102 | " - [Simulation](matsuyama.html#simulation)\n", 103 | " - [Exercises](matsuyama.html#exercises)\n", 104 | " - [Solutions](matsuyama.html#solutions)" 105 | ] 106 | } 107 | ], 108 | "metadata": { 109 | "date": 1591310624.9284158, 110 | "download_nb": 1, 111 | "download_nb_path": "https://julia.quantecon.org/", 112 | "filename": "index.rst", 113 | "filename_with_path": "multi_agent_models/index", 114 | "kernelspec": { 115 | "display_name": "Julia 1.4.2", 116 | "language": "julia", 117 | "name": "julia-1.4" 118 | }, 119 | "language_info": { 120 | "file_extension": ".jl", 121 | "mimetype": "application/julia", 122 | "name": "julia", 123 | "version": "1.4.2" 124 | }, 125 | "title": "Multiple Agent Models" 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 2 129 | } 130 | -------------------------------------------------------------------------------- /more_julia/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Packages and Software Engineering in Julia\n", 21 | "\n", 22 | "This part of the course provides more details on the Julia programming language, its ecosystem, and core software engineering tools." 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "## Lectures\n", 30 | "\n", 31 | "- [Generic Programming](generic_programming.html)\n", 32 | " - [Overview](generic_programming.html#overview)\n", 33 | " - [Exploring Type Trees](generic_programming.html#exploring-type-trees)\n", 34 | " - [Distributions](generic_programming.html#distributions)\n", 35 | " - [Numbers and Algebraic Structures](generic_programming.html#numbers-and-algebraic-structures)\n", 36 | " - [Reals and Algebraic Structures](generic_programming.html#reals-and-algebraic-structures)\n", 37 | " - [Functions, and Function-Like Types](generic_programming.html#functions-and-function-like-types)\n", 38 | " - [Limitations of Dispatching on Abstract Types](generic_programming.html#limitations-of-dispatching-on-abstract-types)\n", 39 | " - [Exercises](generic_programming.html#exercises)\n", 40 | "- [General Purpose Packages](general_packages.html)\n", 41 | " - [Overview](general_packages.html#overview)\n", 42 | " - [Numerical Integration](general_packages.html#numerical-integration)\n", 43 | " - [Interpolation](general_packages.html#interpolation)\n", 44 | " - [Linear Algebra](general_packages.html#linear-algebra)\n", 45 | " - [General Tools](general_packages.html#general-tools)\n", 46 | "- [Data and Statistics Packages](data_statistical_packages.html)\n", 47 | " - [Overview](data_statistical_packages.html#overview)\n", 48 | " - [DataFrames](data_statistical_packages.html#dataframes)\n", 49 | " - [Statistics and Econometrics](data_statistical_packages.html#statistics-and-econometrics)\n", 50 | "- [Solvers, Optimizers, and Automatic Differentiation](optimization_solver_packages.html)\n", 51 | " - [Overview](optimization_solver_packages.html#overview)\n", 52 | " - [Introduction to Differentiable Programming](optimization_solver_packages.html#introduction-to-differentiable-programming)\n", 53 | " - [Optimization](optimization_solver_packages.html#optimization)\n", 54 | " - [Systems of Equations and Least Squares](optimization_solver_packages.html#systems-of-equations-and-least-squares)\n", 55 | " - [LeastSquaresOptim.jl](optimization_solver_packages.html#leastsquaresoptim-jl)\n", 56 | " - [Additional Notes](optimization_solver_packages.html#additional-notes)\n", 57 | " - [Exercises](optimization_solver_packages.html#exercises)\n", 58 | "- [Julia Tools and Editors](tools_editors.html)\n", 59 | " - [Preliminary Setup](tools_editors.html#preliminary-setup)\n", 60 | " - [The REPL](tools_editors.html#the-repl)\n", 61 | " - [Atom](tools_editors.html#atom)\n", 62 | " - [Package Environments](tools_editors.html#package-environments)\n", 63 | "- [Git, GitHub, and Version Control](version_control.html)\n", 64 | " - [Setup](version_control.html#setup)\n", 65 | " - [Basic Objects](version_control.html#basic-objects)\n", 66 | " - [Individual Workflow](version_control.html#individual-workflow)\n", 67 | " - [Collaborative Work](version_control.html#collaborative-work)\n", 68 | " - [Collaboration via Pull Request](version_control.html#collaboration-via-pull-request)\n", 69 | " - [Additional Resources and Troubleshooting](version_control.html#additional-resources-and-troubleshooting)\n", 70 | " - [Exercises](version_control.html#exercises)\n", 71 | "- [Packages, Testing, and Continuous Integration](testing.html)\n", 72 | " - [Project Setup](testing.html#project-setup)\n", 73 | " - [Project Structure](testing.html#project-structure)\n", 74 | " - [Project Workflow](testing.html#project-workflow)\n", 75 | " - [Unit Testing](testing.html#unit-testing)\n", 76 | " - [Continuous Integration with Travis](testing.html#continuous-integration-with-travis)\n", 77 | " - [Code Coverage](testing.html#code-coverage)\n", 78 | " - [Pull Requests to External Julia Projects](testing.html#pull-requests-to-external-julia-projects)\n", 79 | " - [Benchmarking](testing.html#benchmarking)\n", 80 | " - [Additional Notes](testing.html#additional-notes)\n", 81 | " - [Review](testing.html#review)\n", 82 | " - [Exercises](testing.html#exercises)\n", 83 | "- [The Need for Speed](need_for_speed.html)\n", 84 | " - [Overview](need_for_speed.html#overview)\n", 85 | " - [Understanding Multiple Dispatch in Julia](need_for_speed.html#understanding-multiple-dispatch-in-julia)\n", 86 | " - [Foundations](need_for_speed.html#foundations)\n", 87 | " - [JIT Compilation in Julia](need_for_speed.html#jit-compilation-in-julia)\n", 88 | " - [Fast and Slow Julia Code](need_for_speed.html#fast-and-slow-julia-code)\n", 89 | " - [Further Comments](need_for_speed.html#further-comments)" 90 | ] 91 | } 92 | ], 93 | "metadata": { 94 | "date": 1591310623.0665092, 95 | "download_nb": 1, 96 | "download_nb_path": "https://julia.quantecon.org/", 97 | "filename": "index.rst", 98 | "filename_with_path": "more_julia/index", 99 | "kernelspec": { 100 | "display_name": "Julia 1.4.2", 101 | "language": "julia", 102 | "name": "julia-1.4" 103 | }, 104 | "language_info": { 105 | "file_extension": ".jl", 106 | "mimetype": "application/julia", 107 | "name": "julia", 108 | "version": "1.4.2" 109 | }, 110 | "title": "Packages and Software Engineering in Julia" 111 | }, 112 | "nbformat": 4, 113 | "nbformat_minor": 2 114 | } 115 | -------------------------------------------------------------------------------- /tools_and_techniques/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Tools and Techniques\n", 21 | "\n", 22 | "This section of the course contains foundational mathematical and statistical\n", 23 | "tools and techniques." 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Lectures\n", 31 | "\n", 32 | "- [Linear Algebra](linear_algebra.html)\n", 33 | " - [Overview](linear_algebra.html#overview)\n", 34 | " - [Vectors](linear_algebra.html#vectors)\n", 35 | " - [Matrices](linear_algebra.html#matrices)\n", 36 | " - [Solving Systems of Equations](linear_algebra.html#solving-systems-of-equations)\n", 37 | " - [Eigenvalues and Eigenvectors](linear_algebra.html#eigenvalues-and-eigenvectors)\n", 38 | " - [Further Topics](linear_algebra.html#further-topics)\n", 39 | " - [Exercises](linear_algebra.html#exercises)\n", 40 | " - [Solutions](linear_algebra.html#solutions)\n", 41 | "- [Orthogonal Projections and Their Applications](orth_proj.html)\n", 42 | " - [Overview](orth_proj.html#overview)\n", 43 | " - [Key Definitions](orth_proj.html#key-definitions)\n", 44 | " - [The Orthogonal Projection Theorem](orth_proj.html#the-orthogonal-projection-theorem)\n", 45 | " - [Orthonormal Basis](orth_proj.html#orthonormal-basis)\n", 46 | " - [Projection Using Matrix Algebra](orth_proj.html#projection-using-matrix-algebra)\n", 47 | " - [Least Squares Regression](orth_proj.html#least-squares-regression)\n", 48 | " - [Orthogonalization and Decomposition](orth_proj.html#orthogonalization-and-decomposition)\n", 49 | " - [Exercises](orth_proj.html#exercises)\n", 50 | " - [Solutions](orth_proj.html#solutions)\n", 51 | "- [LLN and CLT](lln_clt.html)\n", 52 | " - [Overview](lln_clt.html#overview)\n", 53 | " - [Relationships](lln_clt.html#relationships)\n", 54 | " - [LLN](lln_clt.html#lln)\n", 55 | " - [CLT](lln_clt.html#clt)\n", 56 | " - [Exercises](lln_clt.html#exercises)\n", 57 | " - [Solutions](lln_clt.html#solutions)\n", 58 | "- [Linear State Space Models](linear_models.html)\n", 59 | " - [Overview](linear_models.html#overview)\n", 60 | " - [The Linear State Space Model](linear_models.html#the-linear-state-space-model)\n", 61 | " - [Distributions and Moments](linear_models.html#distributions-and-moments)\n", 62 | " - [Stationarity and Ergodicity](linear_models.html#stationarity-and-ergodicity)\n", 63 | " - [Noisy Observations](linear_models.html#noisy-observations)\n", 64 | " - [Prediction](linear_models.html#prediction)\n", 65 | " - [Code](linear_models.html#code)\n", 66 | " - [Exercises](linear_models.html#exercises)\n", 67 | " - [Solutions](linear_models.html#solutions)\n", 68 | "- [Finite Markov Chains](finite_markov.html)\n", 69 | " - [Overview](finite_markov.html#overview)\n", 70 | " - [Definitions](finite_markov.html#definitions)\n", 71 | " - [Simulation](finite_markov.html#simulation)\n", 72 | " - [Marginal Distributions](finite_markov.html#marginal-distributions)\n", 73 | " - [Irreducibility and Aperiodicity](finite_markov.html#irreducibility-and-aperiodicity)\n", 74 | " - [Stationary Distributions](finite_markov.html#stationary-distributions)\n", 75 | " - [Ergodicity](finite_markov.html#ergodicity)\n", 76 | " - [Computing Expectations](finite_markov.html#computing-expectations)\n", 77 | " - [Exercises](finite_markov.html#exercises)\n", 78 | " - [Solutions](finite_markov.html#solutions)\n", 79 | "- [Continuous State Markov Chains](stationary_densities.html)\n", 80 | " - [Overview](stationary_densities.html#overview)\n", 81 | " - [The Density Case](stationary_densities.html#the-density-case)\n", 82 | " - [Beyond Densities](stationary_densities.html#beyond-densities)\n", 83 | " - [Stability](stationary_densities.html#stability)\n", 84 | " - [Exercises](stationary_densities.html#exercises)\n", 85 | " - [Solutions](stationary_densities.html#solutions)\n", 86 | " - [Appendix](stationary_densities.html#appendix)\n", 87 | "- [A First Look at the Kalman Filter](kalman.html)\n", 88 | " - [Overview](kalman.html#overview)\n", 89 | " - [The Basic Idea](kalman.html#the-basic-idea)\n", 90 | " - [Convergence](kalman.html#convergence)\n", 91 | " - [Implementation](kalman.html#implementation)\n", 92 | " - [Exercises](kalman.html#exercises)\n", 93 | " - [Solutions](kalman.html#solutions)\n", 94 | "- [Numerical Linear Algebra and Factorizations](numerical_linear_algebra.html)\n", 95 | " - [Overview](numerical_linear_algebra.html#overview)\n", 96 | " - [Factorizations](numerical_linear_algebra.html#factorizations)\n", 97 | " - [Continuous-Time Markov Chains (CTMCs)](numerical_linear_algebra.html#continuous-time-markov-chains-ctmcs)\n", 98 | " - [Banded Matrices](numerical_linear_algebra.html#banded-matrices)\n", 99 | " - [Implementation Details and Performance](numerical_linear_algebra.html#implementation-details-and-performance)\n", 100 | " - [Exercises](numerical_linear_algebra.html#exercises)\n", 101 | "- [Krylov Methods and Matrix Conditioning](iterative_methods_sparsity.html)\n", 102 | " - [Overview](iterative_methods_sparsity.html#overview)\n", 103 | " - [Ill-Conditioned Matrices](iterative_methods_sparsity.html#ill-conditioned-matrices)\n", 104 | " - [Stationary Iterative Algorithms for Linear Systems](iterative_methods_sparsity.html#stationary-iterative-algorithms-for-linear-systems)\n", 105 | " - [Krylov Methods](iterative_methods_sparsity.html#krylov-methods)\n", 106 | " - [Iterative Methods for Linear Least Squares](iterative_methods_sparsity.html#iterative-methods-for-linear-least-squares)\n", 107 | " - [Iterative Methods for Eigensystems](iterative_methods_sparsity.html#iterative-methods-for-eigensystems)\n", 108 | " - [Krylov Methods for Markov-Chain Dynamics](iterative_methods_sparsity.html#krylov-methods-for-markov-chain-dynamics)" 109 | ] 110 | } 111 | ], 112 | "metadata": { 113 | "date": 1591310627.559151, 114 | "download_nb": 1, 115 | "download_nb_path": "https://julia.quantecon.org/", 116 | "filename": "index.rst", 117 | "filename_with_path": "tools_and_techniques/index", 118 | "kernelspec": { 119 | "display_name": "Julia 1.4.2", 120 | "language": "julia", 121 | "name": "julia-1.4" 122 | }, 123 | "language_info": { 124 | "file_extension": ".jl", 125 | "mimetype": "application/julia", 126 | "name": "julia", 127 | "version": "1.4.2" 128 | }, 129 | "title": "Tools and Techniques" 130 | }, 131 | "nbformat": 4, 132 | "nbformat_minor": 2 133 | } 134 | -------------------------------------------------------------------------------- /index_toc.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "

\"Powered

" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Table of Contents\n", 17 | "\n", 18 | "\n", 23 | "\n", 24 | "- [About these Lectures](about_lectures.html)\n", 25 | "- [Getting Started with Julia](getting_started_julia/index.html)\n", 26 | " - [Setting up Your Julia Environment](getting_started_julia/getting_started.html)\n", 27 | " - [Interacting with Julia](getting_started_julia/julia_environment.html)\n", 28 | " - [Introductory Examples](getting_started_julia/julia_by_example.html)\n", 29 | " - [Julia Essentials](getting_started_julia/julia_essentials.html)\n", 30 | " - [Arrays, Tuples, Ranges, and Other Fundamental Types](getting_started_julia/fundamental_types.html)\n", 31 | " - [Introduction to Types and Generic Programming](getting_started_julia/introduction_to_types.html)\n", 32 | "- [Packages and Software Engineering in Julia](more_julia/index.html)\n", 33 | " - [Generic Programming](more_julia/generic_programming.html)\n", 34 | " - [General Purpose Packages](more_julia/general_packages.html)\n", 35 | " - [Data and Statistics Packages](more_julia/data_statistical_packages.html)\n", 36 | " - [Solvers, Optimizers, and Automatic Differentiation](more_julia/optimization_solver_packages.html)\n", 37 | " - [Julia Tools and Editors](more_julia/tools_editors.html)\n", 38 | " - [Git, GitHub, and Version Control](more_julia/version_control.html)\n", 39 | " - [Packages, Testing, and Continuous Integration](more_julia/testing.html)\n", 40 | " - [The Need for Speed](more_julia/need_for_speed.html)\n", 41 | "- [Tools and Techniques](tools_and_techniques/index.html)\n", 42 | " - [Linear Algebra](tools_and_techniques/linear_algebra.html)\n", 43 | " - [Orthogonal Projections and Their Applications](tools_and_techniques/orth_proj.html)\n", 44 | " - [LLN and CLT](tools_and_techniques/lln_clt.html)\n", 45 | " - [Linear State Space Models](tools_and_techniques/linear_models.html)\n", 46 | " - [Finite Markov Chains](tools_and_techniques/finite_markov.html)\n", 47 | " - [Continuous State Markov Chains](tools_and_techniques/stationary_densities.html)\n", 48 | " - [A First Look at the Kalman Filter](tools_and_techniques/kalman.html)\n", 49 | " - [Numerical Linear Algebra and Factorizations](tools_and_techniques/numerical_linear_algebra.html)\n", 50 | " - [Krylov Methods and Matrix Conditioning](tools_and_techniques/iterative_methods_sparsity.html)\n", 51 | "- [Dynamic Programming](dynamic_programming/index.html)\n", 52 | " - [Shortest Paths](dynamic_programming/short_path.html)\n", 53 | " - [Job Search I: The McCall Search Model](dynamic_programming/mccall_model.html)\n", 54 | " - [Job Search II: Search and Separation](dynamic_programming/mccall_model_with_separation.html)\n", 55 | " - [A Problem that Stumped Milton Friedman](dynamic_programming/wald_friedman.html)\n", 56 | " - [Job Search III: Search with Learning](dynamic_programming/odu.html)\n", 57 | " - [Job Search IV: Modeling Career Choice](dynamic_programming/career.html)\n", 58 | " - [Job Search V: On-the-Job Search](dynamic_programming/jv.html)\n", 59 | " - [Optimal Growth I: The Stochastic Optimal Growth Model](dynamic_programming/optgrowth.html)\n", 60 | " - [Optimal Growth II: Time Iteration](dynamic_programming/coleman_policy_iter.html)\n", 61 | " - [Optimal Growth III: The Endogenous Grid Method](dynamic_programming/egm_policy_iter.html)\n", 62 | " - [LQ Dynamic Programming Problems](dynamic_programming/lqcontrol.html)\n", 63 | " - [Optimal Savings I: The Permanent Income Model](dynamic_programming/perm_income.html)\n", 64 | " - [Optimal Savings II: LQ Techniques](dynamic_programming/perm_income_cons.html)\n", 65 | " - [Consumption and Tax Smoothing with Complete and Incomplete Markets](dynamic_programming/smoothing.html)\n", 66 | " - [Optimal Savings III: Occasionally Binding Constraints](dynamic_programming/ifp.html)\n", 67 | " - [Robustness](dynamic_programming/robustness.html)\n", 68 | " - [Discrete State Dynamic Programming](dynamic_programming/discrete_dp.html)\n", 69 | "- [Multiple Agent Models](multi_agent_models/index.html)\n", 70 | " - [Schelling’s Segregation Model](multi_agent_models/schelling.html)\n", 71 | " - [A Lake Model of Employment and Unemployment](multi_agent_models/lake_model.html)\n", 72 | " - [Rational Expectations Equilibrium](multi_agent_models/rational_expectations.html)\n", 73 | " - [Markov Perfect Equilibrium](multi_agent_models/markov_perf.html)\n", 74 | " - [Asset Pricing I: Finite State Models](multi_agent_models/markov_asset.html)\n", 75 | " - [Asset Pricing II: The Lucas Asset Pricing Model](multi_agent_models/lucas_model.html)\n", 76 | " - [Asset Pricing III: Incomplete Markets](multi_agent_models/harrison_kreps.html)\n", 77 | " - [Uncertainty Traps](multi_agent_models/uncertainty_traps.html)\n", 78 | " - [The Aiyagari Model](multi_agent_models/aiyagari.html)\n", 79 | " - [Default Risk and Income Fluctuations](multi_agent_models/arellano.html)\n", 80 | " - [Globalization and Cycles](multi_agent_models/matsuyama.html)\n", 81 | "- [Time Series Models](time_series_models/index.html)\n", 82 | " - [Covariance Stationary Processes](time_series_models/arma.html)\n", 83 | " - [Estimation of Spectra](time_series_models/estspec.html)\n", 84 | " - [Additive Functionals](time_series_models/additive_functionals.html)\n", 85 | " - [Multiplicative Functionals](time_series_models/multiplicative_functionals.html)\n", 86 | " - [Classical Control with Linear Algebra](time_series_models/lu_tricks.html)\n", 87 | " - [Classical Filtering With Linear Algebra](time_series_models/classical_filtering.html)\n", 88 | "- [Dynamic Programming Squared](dynamic_programming_squared/index.html)\n", 89 | " - [Dynamic Stackelberg Problems](dynamic_programming_squared/dyn_stack.html)\n", 90 | " - [Optimal Taxation in an LQ Economy](dynamic_programming_squared/lqramsey.html)\n", 91 | " - [Optimal Taxation with State-Contingent Debt](dynamic_programming_squared/opt_tax_recur.html)\n", 92 | " - [Optimal Taxation without State-Contingent Debt](dynamic_programming_squared/amss.html)\n", 93 | "- [References](zreferences.html)\n", 94 | "\n", 95 | "\n", 96 | "" 97 | ] 98 | } 99 | ], 100 | "metadata": { 101 | "date": 1591310622.1148598, 102 | "download_nb": 1, 103 | "download_nb_path": "https://julia.quantecon.org/", 104 | "filename": "index_toc.rst", 105 | "filename_with_path": "index_toc", 106 | "kernelspec": { 107 | "display_name": "Julia 1.4.2", 108 | "language": "julia", 109 | "name": "julia-1.4" 110 | }, 111 | "language_info": { 112 | "file_extension": ".jl", 113 | "mimetype": "application/julia", 114 | "name": "julia", 115 | "version": "1.4.2" 116 | }, 117 | "title": "Table of Contents" 118 | }, 119 | "nbformat": 4, 120 | "nbformat_minor": 2 121 | } 122 | -------------------------------------------------------------------------------- /dynamic_programming/index_grad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Dynamic Programming\n", 21 | "\n", 22 | "This section of the course contains foundational models for dynamic economic\n", 23 | "modeling. Most are single agent problems that take the activities of other\n", 24 | "agents as given. Later we will look at full equilibrium problems." 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "## Lectures\n", 32 | "\n", 33 | "- [Job Search I: The McCall Search Model](mccall_model.html)\n", 34 | " - [Overview](mccall_model.html#overview)\n", 35 | " - [The McCall Model](mccall_model.html#the-mccall-model)\n", 36 | " - [Computing the Optimal Policy: Take 1](mccall_model.html#computing-the-optimal-policy-take-1)\n", 37 | " - [Computing the Optimal Policy: Take 2](mccall_model.html#computing-the-optimal-policy-take-2)\n", 38 | " - [Exercises](mccall_model.html#exercises)\n", 39 | " - [Solutions](mccall_model.html#solutions)\n", 40 | "- [Job Search II: Search and Separation](mccall_model_with_separation.html)\n", 41 | " - [Overview](mccall_model_with_separation.html#overview)\n", 42 | " - [The Model](mccall_model_with_separation.html#the-model)\n", 43 | " - [Solving the Model using Dynamic Programming](mccall_model_with_separation.html#solving-the-model-using-dynamic-programming)\n", 44 | " - [Implementation](mccall_model_with_separation.html#implementation)\n", 45 | " - [The Reservation Wage](mccall_model_with_separation.html#the-reservation-wage)\n", 46 | " - [Exercises](mccall_model_with_separation.html#exercises)\n", 47 | " - [Solutions](mccall_model_with_separation.html#solutions)\n", 48 | "- [A Problem that Stumped Milton Friedman](wald_friedman.html)\n", 49 | " - [Overview](wald_friedman.html#overview)\n", 50 | " - [Origin of the problem](wald_friedman.html#origin-of-the-problem)\n", 51 | " - [A dynamic programming approach](wald_friedman.html#a-dynamic-programming-approach)\n", 52 | " - [Implementation](wald_friedman.html#implementation)\n", 53 | " - [Comparison with Neyman-Pearson formulation](wald_friedman.html#comparison-with-neyman-pearson-formulation)\n", 54 | "- [Job Search III: Search with Learning](odu.html)\n", 55 | " - [Overview](odu.html#overview)\n", 56 | " - [Model](odu.html#model)\n", 57 | " - [Take 1: Solution by VFI](odu.html#take-1-solution-by-vfi)\n", 58 | " - [Take 2: A More Efficient Method](odu.html#take-2-a-more-efficient-method)\n", 59 | " - [Exercises](odu.html#exercises)\n", 60 | " - [Solutions](odu.html#solutions)\n", 61 | "- [Job Search IV: Modeling Career Choice](career.html)\n", 62 | " - [Overview](career.html#overview)\n", 63 | " - [Model](career.html#model)\n", 64 | " - [Exercises](career.html#exercises)\n", 65 | " - [Solutions](career.html#solutions)\n", 66 | "- [Job Search V: On-the-Job Search](jv.html)\n", 67 | " - [Overview](jv.html#overview)\n", 68 | " - [Model](jv.html#model)\n", 69 | " - [Implementation](jv.html#implementation)\n", 70 | " - [Solving for Policies](jv.html#solving-for-policies)\n", 71 | " - [Exercises](jv.html#exercises)\n", 72 | " - [Solutions](jv.html#solutions)\n", 73 | "- [Optimal Growth I: The Stochastic Optimal Growth Model](optgrowth.html)\n", 74 | " - [Overview](optgrowth.html#overview)\n", 75 | " - [The Model](optgrowth.html#the-model)\n", 76 | " - [Computation](optgrowth.html#computation)\n", 77 | " - [Exercises](optgrowth.html#exercises)\n", 78 | " - [Solutions](optgrowth.html#solutions)\n", 79 | "- [Optimal Growth II: Time Iteration](coleman_policy_iter.html)\n", 80 | " - [Overview](coleman_policy_iter.html#overview)\n", 81 | " - [The Euler Equation](coleman_policy_iter.html#the-euler-equation)\n", 82 | " - [Comparison with Value Function Iteration](coleman_policy_iter.html#comparison-with-value-function-iteration)\n", 83 | " - [Implementation](coleman_policy_iter.html#implementation)\n", 84 | " - [Exercises](coleman_policy_iter.html#exercises)\n", 85 | " - [Solutions](coleman_policy_iter.html#solutions)\n", 86 | "- [Optimal Growth III: The Endogenous Grid Method](egm_policy_iter.html)\n", 87 | " - [Overview](egm_policy_iter.html#overview)\n", 88 | " - [Key Idea](egm_policy_iter.html#key-idea)\n", 89 | " - [Implementation](egm_policy_iter.html#implementation)\n", 90 | " - [Speed](egm_policy_iter.html#speed)\n", 91 | "- [LQ Dynamic Programming Problems](lqcontrol.html)\n", 92 | " - [Overview](lqcontrol.html#overview)\n", 93 | " - [Introduction](lqcontrol.html#introduction)\n", 94 | " - [Optimality – Finite Horizon](lqcontrol.html#optimality-finite-horizon)\n", 95 | " - [Implementation](lqcontrol.html#implementation)\n", 96 | " - [Extensions and Comments](lqcontrol.html#extensions-and-comments)\n", 97 | " - [Further Applications](lqcontrol.html#further-applications)\n", 98 | " - [Exercises](lqcontrol.html#exercises)\n", 99 | " - [Solutions](lqcontrol.html#solutions)\n", 100 | "- [Optimal Savings III: Occasionally Binding Constraints](ifp.html)\n", 101 | " - [Overview](ifp.html#overview)\n", 102 | " - [The Optimal Savings Problem](ifp.html#the-optimal-savings-problem)\n", 103 | " - [Computation](ifp.html#computation)\n", 104 | " - [Exercises](ifp.html#exercises)\n", 105 | " - [Solutions](ifp.html#solutions)\n", 106 | "- [Robustness](robustness.html)\n", 107 | " - [Overview](robustness.html#overview)\n", 108 | " - [The Model](robustness.html#the-model)\n", 109 | " - [Constructing More Robust Policies](robustness.html#constructing-more-robust-policies)\n", 110 | " - [Robustness as Outcome of a Two-Person Zero-Sum Game](robustness.html#robustness-as-outcome-of-a-two-person-zero-sum-game)\n", 111 | " - [The Stochastic Case](robustness.html#the-stochastic-case)\n", 112 | " - [Implementation](robustness.html#implementation)\n", 113 | " - [Application](robustness.html#application)\n", 114 | " - [Appendix](robustness.html#appendix)\n", 115 | "- [Discrete State Dynamic Programming](discrete_dp.html)\n", 116 | " - [Overview](discrete_dp.html#overview)\n", 117 | " - [Discrete DPs](discrete_dp.html#discrete-dps)\n", 118 | " - [Solving Discrete DPs](discrete_dp.html#solving-discrete-dps)\n", 119 | " - [Example: A Growth Model](discrete_dp.html#example-a-growth-model)\n", 120 | " - [Exercises](discrete_dp.html#exercises)\n", 121 | " - [Solutions](discrete_dp.html#solutions)\n", 122 | " - [Appendix: Algorithms](discrete_dp.html#appendix-algorithms)" 123 | ] 124 | } 125 | ], 126 | "metadata": { 127 | "date": 1591310615.3750706, 128 | "download_nb": 1, 129 | "download_nb_path": "https://julia.quantecon.org/", 130 | "filename": "index_grad.rst", 131 | "filename_with_path": "dynamic_programming/index_grad", 132 | "kernelspec": { 133 | "display_name": "Julia 1.4.2", 134 | "language": "julia", 135 | "name": "julia-1.4" 136 | }, 137 | "language_info": { 138 | "file_extension": ".jl", 139 | "mimetype": "application/julia", 140 | "name": "julia", 141 | "version": "1.4.2" 142 | }, 143 | "title": "Dynamic Programming" 144 | }, 145 | "nbformat": 4, 146 | "nbformat_minor": 2 147 | } 148 | -------------------------------------------------------------------------------- /dynamic_programming/index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Dynamic Programming\n", 21 | "\n", 22 | "This section of the course contains foundational models for dynamic economic\n", 23 | "modeling. Most are single agent problems that take the activities of other\n", 24 | "agents as given. Later we will look at full equilibrium problems." 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "## Lectures\n", 32 | "\n", 33 | "- [Shortest Paths](short_path.html)\n", 34 | " - [Overview](short_path.html#overview)\n", 35 | " - [Outline of the Problem](short_path.html#outline-of-the-problem)\n", 36 | " - [Finding Least-Cost Paths](short_path.html#finding-least-cost-paths)\n", 37 | " - [Solving for $ J $](short_path.html#solving-for-j)\n", 38 | " - [Exercises](short_path.html#exercises)\n", 39 | " - [Solutions](short_path.html#solutions)\n", 40 | "- [Job Search I: The McCall Search Model](mccall_model.html)\n", 41 | " - [Overview](mccall_model.html#overview)\n", 42 | " - [The McCall Model](mccall_model.html#the-mccall-model)\n", 43 | " - [Computing the Optimal Policy: Take 1](mccall_model.html#computing-the-optimal-policy-take-1)\n", 44 | " - [Computing the Optimal Policy: Take 2](mccall_model.html#computing-the-optimal-policy-take-2)\n", 45 | " - [Exercises](mccall_model.html#exercises)\n", 46 | " - [Solutions](mccall_model.html#solutions)\n", 47 | "- [Job Search II: Search and Separation](mccall_model_with_separation.html)\n", 48 | " - [Overview](mccall_model_with_separation.html#overview)\n", 49 | " - [The Model](mccall_model_with_separation.html#the-model)\n", 50 | " - [Solving the Model using Dynamic Programming](mccall_model_with_separation.html#solving-the-model-using-dynamic-programming)\n", 51 | " - [Implementation](mccall_model_with_separation.html#implementation)\n", 52 | " - [The Reservation Wage](mccall_model_with_separation.html#the-reservation-wage)\n", 53 | " - [Exercises](mccall_model_with_separation.html#exercises)\n", 54 | " - [Solutions](mccall_model_with_separation.html#solutions)\n", 55 | "- [A Problem that Stumped Milton Friedman](wald_friedman.html)\n", 56 | " - [Overview](wald_friedman.html#overview)\n", 57 | " - [Origin of the problem](wald_friedman.html#origin-of-the-problem)\n", 58 | " - [A dynamic programming approach](wald_friedman.html#a-dynamic-programming-approach)\n", 59 | " - [Implementation](wald_friedman.html#implementation)\n", 60 | " - [Comparison with Neyman-Pearson formulation](wald_friedman.html#comparison-with-neyman-pearson-formulation)\n", 61 | "- [Job Search III: Search with Learning](odu.html)\n", 62 | " - [Overview](odu.html#overview)\n", 63 | " - [Model](odu.html#model)\n", 64 | " - [Take 1: Solution by VFI](odu.html#take-1-solution-by-vfi)\n", 65 | " - [Take 2: A More Efficient Method](odu.html#take-2-a-more-efficient-method)\n", 66 | " - [Exercises](odu.html#exercises)\n", 67 | " - [Solutions](odu.html#solutions)\n", 68 | "- [Job Search IV: Modeling Career Choice](career.html)\n", 69 | " - [Overview](career.html#overview)\n", 70 | " - [Model](career.html#model)\n", 71 | " - [Exercises](career.html#exercises)\n", 72 | " - [Solutions](career.html#solutions)\n", 73 | "- [Job Search V: On-the-Job Search](jv.html)\n", 74 | " - [Overview](jv.html#overview)\n", 75 | " - [Model](jv.html#model)\n", 76 | " - [Implementation](jv.html#implementation)\n", 77 | " - [Solving for Policies](jv.html#solving-for-policies)\n", 78 | " - [Exercises](jv.html#exercises)\n", 79 | " - [Solutions](jv.html#solutions)\n", 80 | "- [Optimal Growth I: The Stochastic Optimal Growth Model](optgrowth.html)\n", 81 | " - [Overview](optgrowth.html#overview)\n", 82 | " - [The Model](optgrowth.html#the-model)\n", 83 | " - [Computation](optgrowth.html#computation)\n", 84 | " - [Exercises](optgrowth.html#exercises)\n", 85 | " - [Solutions](optgrowth.html#solutions)\n", 86 | "- [Optimal Growth II: Time Iteration](coleman_policy_iter.html)\n", 87 | " - [Overview](coleman_policy_iter.html#overview)\n", 88 | " - [The Euler Equation](coleman_policy_iter.html#the-euler-equation)\n", 89 | " - [Comparison with Value Function Iteration](coleman_policy_iter.html#comparison-with-value-function-iteration)\n", 90 | " - [Implementation](coleman_policy_iter.html#implementation)\n", 91 | " - [Exercises](coleman_policy_iter.html#exercises)\n", 92 | " - [Solutions](coleman_policy_iter.html#solutions)\n", 93 | "- [Optimal Growth III: The Endogenous Grid Method](egm_policy_iter.html)\n", 94 | " - [Overview](egm_policy_iter.html#overview)\n", 95 | " - [Key Idea](egm_policy_iter.html#key-idea)\n", 96 | " - [Implementation](egm_policy_iter.html#implementation)\n", 97 | " - [Speed](egm_policy_iter.html#speed)\n", 98 | "- [LQ Dynamic Programming Problems](lqcontrol.html)\n", 99 | " - [Overview](lqcontrol.html#overview)\n", 100 | " - [Introduction](lqcontrol.html#introduction)\n", 101 | " - [Optimality – Finite Horizon](lqcontrol.html#optimality-finite-horizon)\n", 102 | " - [Implementation](lqcontrol.html#implementation)\n", 103 | " - [Extensions and Comments](lqcontrol.html#extensions-and-comments)\n", 104 | " - [Further Applications](lqcontrol.html#further-applications)\n", 105 | " - [Exercises](lqcontrol.html#exercises)\n", 106 | " - [Solutions](lqcontrol.html#solutions)\n", 107 | "- [Optimal Savings I: The Permanent Income Model](perm_income.html)\n", 108 | " - [Overview](perm_income.html#overview)\n", 109 | " - [The Savings Problem](perm_income.html#the-savings-problem)\n", 110 | " - [Alternative Representations](perm_income.html#alternative-representations)\n", 111 | " - [Two Classic Examples](perm_income.html#two-classic-examples)\n", 112 | " - [Further Reading](perm_income.html#further-reading)\n", 113 | " - [Appendix: the Euler Equation](perm_income.html#appendix-the-euler-equation)\n", 114 | "- [Optimal Savings II: LQ Techniques](perm_income_cons.html)\n", 115 | " - [Overview](perm_income_cons.html#overview)\n", 116 | " - [Introduction](perm_income_cons.html#introduction)\n", 117 | " - [The LQ Approach](perm_income_cons.html#the-lq-approach)\n", 118 | " - [Implementation](perm_income_cons.html#implementation)\n", 119 | " - [Two Example Economies](perm_income_cons.html#two-example-economies)\n", 120 | "- [Consumption and Tax Smoothing with Complete and Incomplete Markets](smoothing.html)\n", 121 | " - [Overview](smoothing.html#overview)\n", 122 | " - [Background](smoothing.html#background)\n", 123 | " - [Model 1 (Complete Markets)](smoothing.html#model-1-complete-markets)\n", 124 | " - [Model 2 (One-Period Risk Free Debt Only)](smoothing.html#model-2-one-period-risk-free-debt-only)\n", 125 | " - [Example: Tax Smoothing with Complete Markets](smoothing.html#example-tax-smoothing-with-complete-markets)\n", 126 | " - [Linear State Space Version of Complete Markets Model](smoothing.html#linear-state-space-version-of-complete-markets-model)\n", 127 | "- [Optimal Savings III: Occasionally Binding Constraints](ifp.html)\n", 128 | " - [Overview](ifp.html#overview)\n", 129 | " - [The Optimal Savings Problem](ifp.html#the-optimal-savings-problem)\n", 130 | " - [Computation](ifp.html#computation)\n", 131 | " - [Exercises](ifp.html#exercises)\n", 132 | " - [Solutions](ifp.html#solutions)\n", 133 | "- [Robustness](robustness.html)\n", 134 | " - [Overview](robustness.html#overview)\n", 135 | " - [The Model](robustness.html#the-model)\n", 136 | " - [Constructing More Robust Policies](robustness.html#constructing-more-robust-policies)\n", 137 | " - [Robustness as Outcome of a Two-Person Zero-Sum Game](robustness.html#robustness-as-outcome-of-a-two-person-zero-sum-game)\n", 138 | " - [The Stochastic Case](robustness.html#the-stochastic-case)\n", 139 | " - [Implementation](robustness.html#implementation)\n", 140 | " - [Application](robustness.html#application)\n", 141 | " - [Appendix](robustness.html#appendix)\n", 142 | "- [Discrete State Dynamic Programming](discrete_dp.html)\n", 143 | " - [Overview](discrete_dp.html#overview)\n", 144 | " - [Discrete DPs](discrete_dp.html#discrete-dps)\n", 145 | " - [Solving Discrete DPs](discrete_dp.html#solving-discrete-dps)\n", 146 | " - [Example: A Growth Model](discrete_dp.html#example-a-growth-model)\n", 147 | " - [Exercises](discrete_dp.html#exercises)\n", 148 | " - [Solutions](discrete_dp.html#solutions)\n", 149 | " - [Appendix: Algorithms](discrete_dp.html#appendix-algorithms)" 150 | ] 151 | } 152 | ], 153 | "metadata": { 154 | "date": 1591310615.3227003, 155 | "download_nb": 1, 156 | "download_nb_path": "https://julia.quantecon.org/", 157 | "filename": "index.rst", 158 | "filename_with_path": "dynamic_programming/index", 159 | "kernelspec": { 160 | "display_name": "Julia 1.4.2", 161 | "language": "julia", 162 | "name": "julia-1.4" 163 | }, 164 | "language_info": { 165 | "file_extension": ".jl", 166 | "mimetype": "application/julia", 167 | "name": "julia", 168 | "version": "1.4.2" 169 | }, 170 | "title": "Dynamic Programming" 171 | }, 172 | "nbformat": 4, 173 | "nbformat_minor": 2 174 | } 175 | -------------------------------------------------------------------------------- /about_lectures.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# About these Lectures" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "## Overview\n", 23 | "\n", 24 | "Programming, mathematics and statistics are powerful tools for analyzing the functioning of economies.\n", 25 | "\n", 26 | "This lecture series provides a hands-on instruction manual.\n", 27 | "\n", 28 | "Topics include\n", 29 | "\n", 30 | "- algorithms and numerical methods for studying economic problems, \n", 31 | "- related mathematical and statistical concepts, and \n", 32 | "- basics of coding skills and software engineering. \n", 33 | "\n", 34 | "\n", 35 | "The intended audience is undergraduate students, graduate students and\n", 36 | "researchers in economics, finance and related fields." 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "## Julia\n", 44 | "\n", 45 | "The coding language for this lecture series is Julia.\n", 46 | "\n", 47 | "Note that there’s also a related set of [Python lectures](https://python.quantecon.org).\n", 48 | "\n", 49 | "In terms of the differences,\n", 50 | "\n", 51 | "- Python is a general purpose language featuring a huge user community in the sciences and an outstanding scientific and general ecosystem. \n", 52 | "- Julia is a more focused language primarily used in technical and scientific computing, with an outstanding ecosystem for cutting-edge methods and algorithms. \n", 53 | "\n", 54 | "\n", 55 | "Both are modern, open source, high productivity languages with all the key features needed for\n", 56 | "high performance computing.\n", 57 | "\n", 58 | "While Julia has many features of a general purpose language, its specialization makes it much closer to\n", 59 | "using Matlab or Fortran than using a general purpose language - giving it an advantage in being closer\n", 60 | "to both mathematical notation and direct implementation of mathematical abstractions." 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "### A Word of Caution\n", 68 | "\n", 69 | "The disadvantage of specialization is that Julia tends to be used by domain experts, and consequently\n", 70 | "the ecosystem and language for non-mathematical/non-scientfic computing tasks is inferior to Python.\n", 71 | "\n", 72 | "Another disadvantage is that, since it tends to be used by experts and is on the cutting edge, the tooling is\n", 73 | "much more fragile and rudimentary than Matlab.\n", 74 | "\n", 75 | "Thankfully, with the v1.x release of Julia the fragility no longer applies to the language itself - now stable and\n", 76 | "carefully managed for [version compatibility](https://semver.org/). However, casual users should\n", 77 | "not expect the development tools to quite as stable, or to be comparable to Matlab.\n", 78 | "\n", 79 | "Nevertheless, the end-result will always be elegant and grounded in mathematical notation and abstractions.\n", 80 | "\n", 81 | "For these reasons, Julia is most appropriate at this time for researchers who want to:\n", 82 | "\n", 83 | "1. invest in a language likely to mature in the 3-5 year timeline \n", 84 | "1. use one of the many amazing packages that Julia makes possible (and are frequently impossible in other languages) \n", 85 | "1. write sufficiently specialized algorithms that the quirks of the environment are much less important than the end-result " 86 | ] 87 | }, 88 | { 89 | "cell_type": "markdown", 90 | "metadata": {}, 91 | "source": [ 92 | "## Advantages of Julia\n", 93 | "\n", 94 | "Despite the short-term cautions, Julia has both immediate and long-run advantages.\n", 95 | "\n", 96 | "The advantages of the language itself show clearly in the high quality packages, such as\n", 97 | "\n", 98 | "- Differential Equations: [DifferentialEquations.jl](http://docs.juliadiffeq.org/latest/) \n", 99 | "- Function approximation and manipulation: [ApproxFun.jl](https://github.com/JuliaApproximation/ApproxFun.jl) \n", 100 | "- Interval Constraint Programming and rigorous root finding: [IntervalRootFinding.jl](https://github.com/JuliaIntervals/IntervalRootFinding.jl) \n", 101 | "- GPUs: [CuArrays.jl](https://github.com/JuliaGPU/CuArrays.jl) \n", 102 | "- Linear algebra for large-systems (e.g. structured matrices, matrix-free methods, etc.): [IterativeSolvers.jl](https://juliamath.github.io/IterativeSolvers.jl/dev/), [BlockBandedMatrices.jl](https://github.com/JuliaMatrices/BlockBandedMatrices.jl), [InfiniteLinearAlgebra.jl](https://github.com/JuliaMatrices/InfiniteLinearAlgebra.jl), and many others \n", 103 | "- Automatic differentiation: [Zygote.jl](https://github.com/FluxML/Zygote.jl) and [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) \n", 104 | "\n", 105 | "\n", 106 | "These are in addition to the many mundane but essential packages available. While there are examples of these packages in other languages, no\n", 107 | "other language can achieve the combination of performance, mathematical notation, and composition that Julia provides.\n", 108 | "\n", 109 | "The composition of packages is especially important, and is made possible through Julia’s use of something called [multiple-dispatch](https://en.wikipedia.org/wiki/Multiple_dispatch).\n", 110 | "\n", 111 | "The promise of Julia is that you write clean mathematical code, and have the same code automatically work with automatic-differentiation, interval arithmetic, and GPU arrays–all of which may be used in\n", 112 | "cutting edge algorithms in packages and combined seamlessly." 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "## Open Source\n", 120 | "\n", 121 | "All the computing environments we work with are free and open source.\n", 122 | "\n", 123 | "This means that you, your coauthors and your students can install them and their libraries on all of your computers without cost or concern about licenses.\n", 124 | "\n", 125 | "Another advantage of open source libraries is that you can read them and learn\n", 126 | "how they work.\n", 127 | "\n", 128 | "For example, let’s say you want to know exactly how [Distributions.jl](https://github.com/JuliaStats/Distributions.jl) implements mean of the exponential function\n", 129 | "\n", 130 | "No problem: You can go ahead and [read the code](https://github.com/JuliaStats/Distributions.jl/blob/master/src/univariate/continuous/exponential.jl#L56).\n", 131 | "\n", 132 | "This goes even further since most of Julia is written in Julia. For example, you could see the code for how the standard library calculates the [eigenvalues of a triangular matrix](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/triangular.jl#L2594) or calculates the [mean of a range](https://github.com/JuliaLang/julia/blob/master/stdlib/Statistics/src/Statistics.jl#L162)\n", 133 | "\n", 134 | "Those two examples also provide examples where the “multiple dispatch” allows exploitation of the structure of a problem, leading to specialized algorithms (e.g. if the user calls `eigvals` on a matrix that happens to be triangular, it just needs to return the diagonal).\n", 135 | "\n", 136 | "While dipping into external code libraries takes a bit of coding maturity, it’s very useful for\n", 137 | "\n", 138 | "1. helping you understand the details of a particular implementation, and \n", 139 | "1. building your programming skills by showing you code written by first rate programmers. \n", 140 | "\n", 141 | "\n", 142 | "Also, you can modify the library to suit your needs: if the functionality provided is not exactly what you want, you are free to change it.\n", 143 | "\n", 144 | "Another, more philosophical advantage of open source software is that it conforms to the [scientific ideal of reproducibility](https://en.wikipedia.org/wiki/Scientific_method)." 145 | ] 146 | }, 147 | { 148 | "cell_type": "markdown", 149 | "metadata": {}, 150 | "source": [ 151 | "## How about Other Languages?\n", 152 | "\n", 153 | "But why don’t you use language XYZ?" 154 | ] 155 | }, 156 | { 157 | "cell_type": "markdown", 158 | "metadata": {}, 159 | "source": [ 160 | "### MATLAB\n", 161 | "\n", 162 | "While MATLAB has many nice features, it’s starting to show its age.\n", 163 | "\n", 164 | "It can no longer match Python or Julia in terms of performance and design.\n", 165 | "\n", 166 | "MATLAB is also proprietary, which comes with its own set of disadvantages.\n", 167 | "\n", 168 | "In particular, the Achilles Heel of Matlab is its lack of a package management\n", 169 | "system, which means that either you need to (1) rely on Matlab’s own packages, which\n", 170 | "are mostly written for engineers and not economists; (2) write the code\n", 171 | "yourself; or (3) use unreliable and manual ways to share code (e.g. email or downloading a zip).\n", 172 | "\n", 173 | "If you are a structural engineer or designing a microcontroller, then Matlab provides a coherent set of packages that takes care of all of your needs.\n", 174 | "\n", 175 | "For economists, on the other hand, the expansion in complexity of numerical methods, the need for researchers to\n", 176 | "collaborate on code, fix bugs, deploy improvements, and have dependencies (i.e. packages relying on other packges) has increased past what Matlab can handle.\n", 177 | "\n", 178 | "Given what’s available now, it’s hard to find any good reasons to invest in MATLAB.\n", 179 | "\n", 180 | "Incidentally, if you decide to jump from MATLAB to Julia, [this cheat-sheet](http://cheatsheets.quantecon.org/) will be useful." 181 | ] 182 | }, 183 | { 184 | "cell_type": "markdown", 185 | "metadata": {}, 186 | "source": [ 187 | "### R\n", 188 | "\n", 189 | "[R](https://cran.r-project.org/) is a very useful open source statistical environment and programming language\n", 190 | "\n", 191 | "Its primary strength is its [vast collection](https://cran.r-project.org/web/packages) of extension packages\n", 192 | "\n", 193 | "Julia is more general purpose than R and hence a better fit for this course" 194 | ] 195 | }, 196 | { 197 | "cell_type": "markdown", 198 | "metadata": {}, 199 | "source": [ 200 | "### C / C++ / Fortran?\n", 201 | "\n", 202 | "Isn’t Fortran / C / C++ faster than Julia? In which case it must be better, right?\n", 203 | "\n", 204 | "For the same algorithms, as a compiled language Julia can often achieve a similar level of performance to those languages.\n", 205 | "\n", 206 | "But even when it doesn’t, keep in mind that the correct objective function to minimize: total time = development time + execution time\n", 207 | "\n", 208 | "In assessing this trade off, it’s necessary to bear in mind that\n", 209 | "\n", 210 | "- Your time is a far more valuable resource than the computer’s time. \n", 211 | "- Languages like Julia are much faster to write and debug in. \n", 212 | "- In any one program, the vast majority of CPU time will be spent iterating over just a few lines of your code. \n", 213 | "\n", 214 | "\n", 215 | "The other issue with all three languages, as with Matlab, is the lack of a package management system. Collaborating on C++ or Fortran packages and distributing code between researchers is difficult, and many\n", 216 | "of the criticisms of matlab equally apply.\n", 217 | "\n", 218 | "Finally, the first-order question of performance is which algorithm you are using, and whether it exploits the structure of the problem. The right algorithm in Matlab or Python is typically faster than the wrong\n", 219 | "algorithm in Fortran - and the right algorithm in Fortran and Julia can be made roughly comparable.\n", 220 | "\n", 221 | "When considering the performance advantages, remember that the design and package system of Julia make it easy to try out algorithms that exploit structure of the problem. We will investigate this more in [Introductory Examples](getting_started_julia/julia_by_example.html#julia-by-example)" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "#### Last Word\n", 229 | "\n", 230 | "Writing your entire program in Fortran / C / C++ is best thought of as “premature optimization”\n", 231 | "\n", 232 | "On this topic we quote the godfather:\n", 233 | "\n", 234 | "> We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. – [Donald Knuth](https://en.wikipedia.org/wiki/Donald_Knuth)\n", 235 | "\n", 236 | "\n", 237 | "But, to put the final part of the quote\n", 238 | "\n", 239 | "> … Yet we should not pass up our opportunities in that critical 3%. – [Donald Knuth](https://en.wikipedia.org/wiki/Donald_Knuth)\n", 240 | "\n", 241 | "\n", 242 | "Julia is an excellent language to attain those last few percent, without having to resort to C or Fortran code and mix languages in your project" 243 | ] 244 | }, 245 | { 246 | "cell_type": "markdown", 247 | "metadata": {}, 248 | "source": [ 249 | "## Credits\n", 250 | "\n", 251 | "These lectures have benefited greatly from comments and suggestions from our\n", 252 | "colleagues, students and friends. Special thanks are due to our sponsoring\n", 253 | "organization the Alfred P. Sloan Foundation and our research assistants Chase\n", 254 | "Coleman, Spencer Lyon and Matthew McKay for innumerable contributions to the\n", 255 | "code library and functioning of the website.\n", 256 | "\n", 257 | "We also thank [Andrij Stachurski](http://drdrij.com/) for his great web\n", 258 | "skills, and the many others who have contributed suggestions, bug fixes or\n", 259 | "improvements. They include but are not limited to Anmol Bhandari, Long Bui,\n", 260 | "Jeong-Hun Choi, David Evans, Xiaojun Guan, Shunsuke Hori, Chenghan Hou, Doc-Jin Jang, Adam Jozefiak,\n", 261 | "Qingyin Ma, Akira Matsushita, Tomohito Okabe, Daisuke Oyama, David Pugh, Alex\n", 262 | "Olssen, Nathan Palmer, Pooya Rashidi Ravari, Arnav Sood, Bill Tubbs, Natasha Watkins, Pablo Winant, Kaan Yolsever and Yixiao\n", 263 | "Zhou." 264 | ] 265 | } 266 | ], 267 | "metadata": { 268 | "date": 1591310614.0218592, 269 | "download_nb": 1, 270 | "download_nb_path": "https://julia.quantecon.org/", 271 | "filename": "about_lectures.rst", 272 | "filename_with_path": "about_lectures", 273 | "kernelspec": { 274 | "display_name": "Julia 1.4.2", 275 | "language": "julia", 276 | "name": "julia-1.4" 277 | }, 278 | "language_info": { 279 | "file_extension": ".jl", 280 | "mimetype": "application/julia", 281 | "name": "julia", 282 | "version": "1.4.2" 283 | }, 284 | "title": "About these Lectures" 285 | }, 286 | "nbformat": 4, 287 | "nbformat_minor": 2 288 | } 289 | -------------------------------------------------------------------------------- /getting_started_julia/getting_started.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Setting up Your Julia Environment" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "## Contents\n", 28 | "\n", 29 | "- [Setting up Your Julia Environment](#Setting-up-Your-Julia-Environment) \n", 30 | " - [Overview](#Overview) \n", 31 | " - [A Note on Jupyter](#A-Note-on-Jupyter) \n", 32 | " - [Desktop Installation of Julia and Jupyter](#Desktop-Installation-of-Julia-and-Jupyter) \n", 33 | " - [Using Julia on the Web](#Using-Julia-on-the-Web) \n", 34 | " - [Installing Packages](#Installing-Packages) " 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "## Overview\n", 42 | "\n", 43 | "In this lecture we will cover how to get up and running with Julia.\n", 44 | "\n", 45 | "There are a few different options for using Julia, including a [local desktop installation](#jl-jupyterlocal) and [Jupyter hosted on the web](#jl-jupyterhub).\n", 46 | "\n", 47 | "If you have access to a web-based Jupyter and Julia setup, it is typically the most straightforward way to get started." 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "## A Note on Jupyter\n", 55 | "\n", 56 | "Like Python and R, and unlike products such as Matlab and Stata, there is a looser connection between Julia as a programming language and Julia as a specific development environment.\n", 57 | "\n", 58 | "While you will eventually use other editors, there are some advantages to starting with the [Jupyter](http://jupyter.org/) environment while learning Julia.\n", 59 | "\n", 60 | "- The ability to mix formatted text (including mathematical expressions) and code in a single document. \n", 61 | "- Nicely formatted output including tables, figures, animation, video, etc. \n", 62 | "- Conversion tools to generate PDF slides, static HTML, etc. \n", 63 | "- [Online Jupyter](#jl-jupyterhub) may be available, and requires no installation. \n", 64 | "\n", 65 | "\n", 66 | "We’ll discuss the workflow on these features in the [next lecture](julia_environment.html).\n", 67 | "\n", 68 | "\n", 69 | "" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "## Desktop Installation of Julia and Jupyter\n", 77 | "\n", 78 | "If you want to install these tools locally on your machine\n", 79 | "\n", 80 | "- Download and install Julia, from [download page](http://julialang.org/downloads/) , accepting all default options. \n", 81 | " \n", 82 | " - We do **not** recommend [JuliaPro](https://juliacomputing.com/products/juliapro.html). \n", 83 | " \n", 84 | "\n", 85 | "\n", 86 | "\n", 87 | "\n", 88 | "- Open Julia, by either \n", 89 | " \n", 90 | " 1. Navigating to Julia through your menus or desktop icons (Windows, Mac), or \n", 91 | " 1. Opening a terminal and typing `julia` (Linux; to set this up on Mac, see end of section) \n", 92 | " \n", 93 | "\n", 94 | "\n", 95 | "You should now be looking at something like this\n", 96 | "\n", 97 | "\n", 98 | "\n", 99 | " \n", 100 | "This is called the JULIA *REPL* (Read-Evaluate-Print-Loop), which we discuss more [later](../more_julia/tools_editors.html#repl-main).\n", 101 | "\n", 102 | "- In the Julia REPL, hit `]` to enter package mode and then enter. " 103 | ] 104 | }, 105 | { 106 | "cell_type": "markdown", 107 | "metadata": { 108 | "hide-output": false 109 | }, 110 | "source": [ 111 | "```julia\n", 112 | "add IJulia InstantiateFromURL\n", 113 | "```\n" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "This adds packages for\n", 121 | "\n", 122 | "- The `IJulia` kernel which links Julia to Jupyter (i.e., allows your browser to run Julia code, manage Julia packages, etc.). \n", 123 | "- The `InstantiateFromURL` which is a tool written by the QE team to manage package dependencies for the lectures. \n", 124 | "\n", 125 | "\n", 126 | "Note: To set up the Julia terminal command on Mac, open a terminal and run `sudo ln -s /Contents/Resources/julia/bin/julia /usr/local/bin/julia`.\n", 127 | "\n", 128 | "The full command might look like `sudo ln -s /Applications/Julia-1.4.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia`, if you placed the app in your `Applications` folder.\n", 129 | "\n", 130 | "**Note**: To obtain the full set of packages we use, at this stage you can run the following (see [the package setup section](#package-setup).)" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": { 136 | "hide-output": false 137 | }, 138 | "source": [ 139 | "```julia\n", 140 | "using InstantiateFromURL\n", 141 | "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.8.0\", instantiate = true, precompile = true)\n", 142 | "```\n" 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "\n", 150 | "" 151 | ] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": {}, 156 | "source": [ 157 | "### Installing Jupyter\n", 158 | "\n", 159 | "If you have previously installed Jupyter (e.g., installing Anaconda Python by downloading the binary )\n", 160 | "then the `add IJulia` installs everything you need into your existing environment.\n", 161 | "\n", 162 | "Otherwise - or in addition - you can install it directly from the Julia REPL" 163 | ] 164 | }, 165 | { 166 | "cell_type": "markdown", 167 | "metadata": { 168 | "hide-output": false 169 | }, 170 | "source": [ 171 | "```julia\n", 172 | "using IJulia; jupyterlab()\n", 173 | "```\n" 174 | ] 175 | }, 176 | { 177 | "cell_type": "markdown", 178 | "metadata": {}, 179 | "source": [ 180 | "Choose the default, `y` if asked to install Jupyter and then JupyterLab via Conda.\n", 181 | "\n", 182 | "After the installation, a JupyterLab tab should open in your browser.\n", 183 | "\n", 184 | "(Optional) To enable launching JupyterLab from a terminal, use [add Julia’s Jupyter to your path](julia_environment.html#add-jupyter-to-path).\n", 185 | "\n", 186 | "\n", 187 | "" 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "metadata": {}, 193 | "source": [ 194 | "### Starting Jupyter\n", 195 | "\n", 196 | "Next, let’s install the QuantEcon lecture notes to our machine and run them (for more details on the tools we’ll use, see our lecture on [version control](../more_julia/version_control.html)).\n", 197 | "\n", 198 | "1. Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git/). \n", 199 | "1. (**Optional, but strongly recommended**) Install the [GitHub Desktop](https://desktop.github.com/). " 200 | ] 201 | }, 202 | { 203 | "cell_type": "markdown", 204 | "metadata": {}, 205 | "source": [ 206 | "#### GitHub Desktop Approach\n", 207 | "\n", 208 | "After installing the Git Desktop application, click [this link](x-github-client://openRepo/https://github.com/QuantEcon/quantecon-notebooks-julia) on your desktop computer to automatically install the notebooks.\n", 209 | "\n", 210 | "It should open a window in the GitHub desktop app like this\n", 211 | "\n", 212 | "\n", 213 | "\n", 214 | " \n", 215 | "Choose a path you like and clone the repo.\n", 216 | "\n", 217 | "**Note:** the workflow will be easiest if you clone the repo to the default location relative to the home folder for your user.\n", 218 | "\n", 219 | "From a Julia REPL, start JupyterLab by executing" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": { 225 | "hide-output": false 226 | }, 227 | "source": [ 228 | "```julia\n", 229 | "using IJulia; jupyterlab()\n", 230 | "```\n" 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "Alternatively, if you installed Jupyter separately in [Jupyter Installation](#jupyter-installation) or [added Jupyter to your path](julia_environment.html#add-jupyter-to-path) then run `jupyter lab` in your terminal.\n", 238 | "\n", 239 | "Navigate to the location you stored the lecture notes, and open the [Interacting with Julia](julia_environment.html) notebook to explore this interface and start writing code." 240 | ] 241 | }, 242 | { 243 | "cell_type": "markdown", 244 | "metadata": {}, 245 | "source": [ 246 | "#### Git Command Line Approach\n", 247 | "\n", 248 | "If you do not wish to install the GitHub Desktop, you can get the notebooks using the Git command-line tool.\n", 249 | "\n", 250 | "Open a new terminal session and run" 251 | ] 252 | }, 253 | { 254 | "cell_type": "markdown", 255 | "metadata": { 256 | "hide-output": false 257 | }, 258 | "source": [ 259 | "```text\n", 260 | "git clone https://github.com/quantecon/quantecon-notebooks-julia\n", 261 | "```\n" 262 | ] 263 | }, 264 | { 265 | "cell_type": "markdown", 266 | "metadata": {}, 267 | "source": [ 268 | "This will download the repository with the notebooks in the working directory.\n", 269 | "\n", 270 | "Then, `cd` to that location in your Mac, Linux, or Windows PowerShell terminal" 271 | ] 272 | }, 273 | { 274 | "cell_type": "markdown", 275 | "metadata": { 276 | "hide-output": false 277 | }, 278 | "source": [ 279 | "```text\n", 280 | "cd quantecon-notebooks-julia\n", 281 | "```\n" 282 | ] 283 | }, 284 | { 285 | "cell_type": "markdown", 286 | "metadata": {}, 287 | "source": [ 288 | "Then, either using the `using IJulia; jupyterlab()` or execute `jupyter lab` within your shell.\n", 289 | "\n", 290 | "And open the [Interacting With Julia](julia_environment.html) lecture (the file `julia_environment.ipynb` in the list of notebooks in JupyterLab) to continue." 291 | ] 292 | }, 293 | { 294 | "cell_type": "markdown", 295 | "metadata": {}, 296 | "source": [ 297 | "## Using Julia on the Web\n", 298 | "\n", 299 | "If you have access to an online Julia installation, it is the easiest way to get started.\n", 300 | "\n", 301 | "Eventually, you will want to do a [local installation](#jl-jupyterlocal) in order to use other\n", 302 | "[tools and editors](../more_julia/tools_editors.html) such as [Atom/Juno](http://junolab.org/), but\n", 303 | "don’t let the environment get in the way of learning the language.\n", 304 | "\n", 305 | "\n", 306 | "" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "metadata": {}, 312 | "source": [ 313 | "### Using Julia with JupyterHub\n", 314 | "\n", 315 | "If you have access to a web-based solution for Jupyter, then that is typically a straightforward option\n", 316 | "\n", 317 | "- Students: ask your department if these resources are available. \n", 318 | "- Universities and workgroups: email [contact@quantecon.org](mailto:contact@quantecon.org\") for\n", 319 | " help on setting up a shared JupyterHub instance with precompiled packages ready for these lecture notes. " 320 | ] 321 | }, 322 | { 323 | "cell_type": "markdown", 324 | "metadata": {}, 325 | "source": [ 326 | "#### Obtaining Notebooks\n", 327 | "\n", 328 | "Your first step is to get a copy of the notebooks in your JupyterHub environment.\n", 329 | "\n", 330 | "While you can individually download the notebooks from the website, the easiest way to access the notebooks is usually to clone the repository with Git into your JupyterHub environment.\n", 331 | "\n", 332 | "JupyterHub installations have different methods for cloning repositories, with which you can use the url for the notebooks repository: [https://github.com/QuantEcon/quantecon-notebooks-julia](https://github.com/QuantEcon/quantecon-notebooks-julia).\n", 333 | "\n", 334 | "\n", 335 | "" 336 | ] 337 | }, 338 | { 339 | "cell_type": "markdown", 340 | "metadata": {}, 341 | "source": [ 342 | "## Installing Packages\n", 343 | "\n", 344 | "After you have some of the notebooks available, as in [above](#clone-lectures), these lectures depend on functionality (like packages for plotting, benchmarking, and statistics) that are not installed with every Jupyter installation on the web.\n", 345 | "\n", 346 | "If your online Jupyter does not come with QuantEcon packages pre-installed, you can install the `InstantiateFromURL` package, which is a tool written by the QE team to manage package dependencies for the lectures.\n", 347 | "\n", 348 | "To add this package, in an online Jupyter notebook run (typically with ``)" 349 | ] 350 | }, 351 | { 352 | "cell_type": "code", 353 | "execution_count": 1, 354 | "metadata": { 355 | "hide-output": true 356 | }, 357 | "outputs": [], 358 | "source": [ 359 | "] add InstantiateFromURL" 360 | ] 361 | }, 362 | { 363 | "cell_type": "markdown", 364 | "metadata": {}, 365 | "source": [ 366 | "Then, run" 367 | ] 368 | }, 369 | { 370 | "cell_type": "markdown", 371 | "metadata": { 372 | "hide-output": false 373 | }, 374 | "source": [ 375 | "```julia\n", 376 | "using InstantiateFromURL\n", 377 | "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.8.0\", instantiate = true, precompile = true)\n", 378 | "```\n" 379 | ] 380 | }, 381 | { 382 | "cell_type": "markdown", 383 | "metadata": {}, 384 | "source": [ 385 | "If your online Jupyter environment does not have the packages pre-installed, it may take 15-20 minutes for your first QuantEcon notebook to run.\n", 386 | "\n", 387 | "After this step, open the downloaded [Interacting with Julia](julia_environment.html) notebook to begin writing code.\n", 388 | "\n", 389 | "If the QuantEcon notebooks do not work after this installation step, you may need to speak to the JupyterHub administrator." 390 | ] 391 | } 392 | ], 393 | "metadata": { 394 | "date": 1591310619.910059, 395 | "download_nb": 1, 396 | "download_nb_path": "https://julia.quantecon.org/", 397 | "filename": "getting_started.rst", 398 | "filename_with_path": "getting_started_julia/getting_started", 399 | "kernelspec": { 400 | "display_name": "Julia 1.4.2", 401 | "language": "julia", 402 | "name": "julia-1.4" 403 | }, 404 | "language_info": { 405 | "file_extension": ".jl", 406 | "mimetype": "application/julia", 407 | "name": "julia", 408 | "version": "1.4.2" 409 | }, 410 | "title": "Setting up Your Julia Environment" 411 | }, 412 | "nbformat": 4, 413 | "nbformat_minor": 2 414 | } 415 | -------------------------------------------------------------------------------- /dynamic_programming/short_path.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Shortest Paths\n", 21 | "\n", 22 | "\n", 23 | "" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "## Contents\n", 31 | "\n", 32 | "- [Shortest Paths](#Shortest-Paths) \n", 33 | " - [Overview](#Overview) \n", 34 | " - [Outline of the Problem](#Outline-of-the-Problem) \n", 35 | " - [Finding Least-Cost Paths](#Finding-Least-Cost-Paths) \n", 36 | " - [Solving for $ J $](#Solving-for-$-J-$) \n", 37 | " - [Exercises](#Exercises) \n", 38 | " - [Solutions](#Solutions) " 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "## Overview\n", 46 | "\n", 47 | "The shortest path problem is a [classic problem](https://en.wikipedia.org/wiki/Shortest_path) in mathematics and computer science with applications in\n", 48 | "\n", 49 | "- Economics (sequential decision making, analysis of social networks, etc.) \n", 50 | "- Operations research and transportation \n", 51 | "- Robotics and artificial intelligence \n", 52 | "- Telecommunication network design and routing \n", 53 | "- etc., etc. \n", 54 | "\n", 55 | "\n", 56 | "Variations of the methods we discuss in this lecture are used millions of times every day, in applications such as\n", 57 | "\n", 58 | "- Google Maps \n", 59 | "- routing packets on the internet \n", 60 | "\n", 61 | "\n", 62 | "For us, the shortest path problem also provides a nice introduction to the logic of **dynamic programming**.\n", 63 | "\n", 64 | "Dynamic programming is an extremely powerful optimization technique that we apply in many lectures on this site." 65 | ] 66 | }, 67 | { 68 | "cell_type": "markdown", 69 | "metadata": {}, 70 | "source": [ 71 | "## Outline of the Problem\n", 72 | "\n", 73 | "The shortest path problem is one of finding how to traverse a [graph](https://en.wikipedia.org/wiki/Graph_%28mathematics%29) from one specified node to another at minimum cost.\n", 74 | "\n", 75 | "Consider the following graph\n", 76 | "\n", 77 | "\n", 78 | "\n", 79 | " \n", 80 | "We wish to travel from node (vertex) A to node G at minimum cost.\n", 81 | "\n", 82 | "- Arrows (edges) indicate the movements we can take. \n", 83 | "- Numbers on edges indicate the cost of traveling that edge. \n", 84 | "\n", 85 | "\n", 86 | "Possible interpretations of the graph include\n", 87 | "\n", 88 | "- Minimum cost for supplier to reach a destination. \n", 89 | "- Routing of packets on the internet (minimize time). \n", 90 | "- Etc., etc. \n", 91 | "\n", 92 | "\n", 93 | "For this simple graph, a quick scan of the edges shows that the optimal paths are\n", 94 | "\n", 95 | "- A, C, F, G at cost 8 \n", 96 | "\n", 97 | "\n", 98 | "\n", 99 | "\n", 100 | " \n", 101 | "- A, D, F, G at cost 8 \n", 102 | "\n", 103 | "\n", 104 | "" 105 | ] 106 | }, 107 | { 108 | "cell_type": "markdown", 109 | "metadata": {}, 110 | "source": [ 111 | "## Finding Least-Cost Paths\n", 112 | "\n", 113 | "For large graphs we need a systematic solution.\n", 114 | "\n", 115 | "Let $ J(v) $ denote the minimum cost-to-go from node $ v $, understood as the total cost from $ v $ if we take the best route.\n", 116 | "\n", 117 | "Suppose that we know $ J(v) $ for each node $ v $, as shown below for the graph from the preceding example\n", 118 | "\n", 119 | "\n", 120 | "\n", 121 | " \n", 122 | "Note that $ J(G) = 0 $.\n", 123 | "\n", 124 | "The best path can now be found as follows\n", 125 | "\n", 126 | "- Start at A. \n", 127 | "- From node v, move to any node that solves \n", 128 | "\n", 129 | "\n", 130 | "\n", 131 | "\n", 132 | "$$\n", 133 | "\\min_{w \\in F_v} \\{ c(v, w) + J(w) \\} \\tag{1}\n", 134 | "$$\n", 135 | "\n", 136 | "where\n", 137 | "\n", 138 | "- $ F_v $ is the set of nodes that can be reached from $ v $ in one step \n", 139 | "- $ c(v, w) $ is the cost of traveling from $ v $ to $ w $ \n", 140 | "\n", 141 | "\n", 142 | "Hence, if we know the function $ J $, then finding the best path is almost trivial.\n", 143 | "\n", 144 | "But how to find $ J $?\n", 145 | "\n", 146 | "Some thought will convince you that, for every node $ v $,\n", 147 | "the function $ J $ satisfies\n", 148 | "\n", 149 | "\n", 150 | "\n", 151 | "$$\n", 152 | "J(v) = \\min_{w \\in F_v} \\{ c(v, w) + J(w) \\} \\tag{2}\n", 153 | "$$\n", 154 | "\n", 155 | "This is known as the *Bellman equation*, after the mathematician Richard Bellman." 156 | ] 157 | }, 158 | { 159 | "cell_type": "markdown", 160 | "metadata": {}, 161 | "source": [ 162 | "## Solving for $ J $\n", 163 | "\n", 164 | "The standard algorithm for finding $ J $ is to start with\n", 165 | "\n", 166 | "\n", 167 | "\n", 168 | "$$\n", 169 | "J_0(v) = M \\text{ if } v \\not= \\text{ destination, else } J_0(v) = 0 \\tag{3}\n", 170 | "$$\n", 171 | "\n", 172 | "where $ M $ is some large number.\n", 173 | "\n", 174 | "Now we use the following algorithm\n", 175 | "\n", 176 | "1. Set $ n = 0 $. \n", 177 | "1. Set $ J_{n+1} (v) = \\min_{w \\in F_v} \\{ c(v, w) + J_n(w) \\} $ for all $ v $. \n", 178 | "1. If $ J_{n+1} $ and $ J_n $ are not equal then increment $ n $, go to 2. \n", 179 | "\n", 180 | "\n", 181 | "In general, this sequence converges to $ J $—the proof is omitted." 182 | ] 183 | }, 184 | { 185 | "cell_type": "markdown", 186 | "metadata": {}, 187 | "source": [ 188 | "## Exercises\n", 189 | "\n", 190 | "\n", 191 | "" 192 | ] 193 | }, 194 | { 195 | "cell_type": "markdown", 196 | "metadata": {}, 197 | "source": [ 198 | "### Exercise 1\n", 199 | "\n", 200 | "Use the algorithm given above to find the optimal path (and its cost) for the\n", 201 | "following graph." 202 | ] 203 | }, 204 | { 205 | "cell_type": "markdown", 206 | "metadata": {}, 207 | "source": [ 208 | "### Setup" 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": 1, 214 | "metadata": { 215 | "hide-output": true 216 | }, 217 | "outputs": [], 218 | "source": [ 219 | "using InstantiateFromURL\n", 220 | "# optionally add arguments to force installation: instantiate = true, precompile = true\n", 221 | "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.8.0\")" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 2, 227 | "metadata": { 228 | "hide-output": false 229 | }, 230 | "outputs": [], 231 | "source": [ 232 | "using LinearAlgebra, Statistics" 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 3, 238 | "metadata": { 239 | "hide-output": false 240 | }, 241 | "outputs": [ 242 | { 243 | "data": { 244 | "text/plain": [ 245 | "Dict{Int64,Array{Tuple{Int64,Float64},1}} with 100 entries:\n", 246 | " 68 => [(71, 1.66), (70, 3.35), (94, 232.1)]\n", 247 | " 2 => [(45, 1561.45), (31, 166.8), (66, 54.18)]\n", 248 | " 89 => [(99, 82.12), (97, 36.97)]\n", 249 | " 11 => [(20, 65.08), (18, 37.55), (94, 4961.32)]\n", 250 | " 39 => [(41, 1.34), (40, 0.95), (50, 39.88)]\n", 251 | " 46 => [(67, 65.48), (57, 27.5), (52, 22.68)]\n", 252 | " 85 => [(89, 4.9), (87, 2.66), (97, 94.51)]\n", 253 | " 25 => [(35, 45.55), (32, 36.58), (70, 1343.63)]\n", 254 | " 55 => [(64, 60.8), (57, 2.13), (84, 86.09)]\n", 255 | " 42 => [(72, 437.49), (47, 10.08), (59, 141.86)]\n", 256 | " 29 => [(33, 12.61), (32, 4.22), (64, 635.52)]\n", 257 | " 58 => [(65, 34.32), (64, 29.85), (83, 556.7)]\n", 258 | " 66 => [(73, 37.53), (68, 2.66), (98, 395.63)]\n", 259 | " 59 => [(71, 0.67), (60, 0.72), (90, 820.66)]\n", 260 | " 8 => [(12, 3.18), (11, 7.45), (69, 577.91)]\n", 261 | " 74 => [(78, 8.08), (76, 0.52), (81, 1.07)]\n", 262 | " 95 => [(99, 0.27), (98, 6.17)]\n", 263 | " 57 => [(60, 7.01), (58, 0.46), (86, 701.09)]\n", 264 | " 20 => [(33, 145.8), (24, 9.81), (98, 3523.33)]\n", 265 | " 90 => [(99, 50.99), (94, 10.47), (96, 23.53)]\n", 266 | " 14 => [(24, 38.65), (16, 2.7), (67, 1878.96)]\n", 267 | " 31 => [(44, 125.88), (36, 20.44), (98, 3350.98)]\n", 268 | " 78 => [(81, 2.59), (98, 355.9)]\n", 269 | " 70 => [(73, 8.37), (72, 1.5), (76, 27.18)]\n", 270 | " 33 => [(47, 111.54), (41, 3.23), (81, 1854.73)]\n", 271 | " ⋮ => ⋮" 272 | ] 273 | }, 274 | "execution_count": 3, 275 | "metadata": {}, 276 | "output_type": "execute_result" 277 | } 278 | ], 279 | "source": [ 280 | "graph = Dict(zip(0:99, [[(14, 72.21), (8, 11.11), (1, 0.04)],[(13, 64.94), (6, 20.59), (46, 1247.25)],[(45, 1561.45), (31, 166.8), (66, 54.18)],[(11, 42.43), (6, 2.06), (20, 133.65)],[(7, 1.02), (5, 0.73), (75, 3706.67)],[(11, 34.54),(7, 3.33),(45, 1382.97)],[(10, 13.1), (9, 0.72), (31, 63.17)],[(10, 5.85), (9, 3.15), (50, 478.14)], [(12, 3.18), (11, 7.45), (69, 577.91)],[(20, 16.53), (13, 4.42), (70, 2454.28)],[(16, 25.16), (12, 1.87), (89, 5352.79)],[(20, 65.08), (18, 37.55), (94, 4961.32)],[(28, 170.04), (24, 34.32), (84, 3914.62)],[(40, 475.33), (38, 236.33), (60, 2135.95)],[(24, 38.65), (16, 2.7),(67, 1878.96)],[(18, 2.57),(17, 1.01),(91, 3597.11)],[(38, 278.71),(19, 3.49),(36, 392.92)],[(23, 26.45), (22, 24.78), (76, 783.29)],[(28, 55.84), (23, 16.23), (91, 3363.17)],[(28, 70.54), (20, 0.24), (26, 20.09)],[(33, 145.8), (24, 9.81),(98, 3523.33)],[(31, 27.06),(28, 36.65),(56, 626.04)], [(40, 124.22), (39, 136.32), (72, 1447.22)],[(33, 22.37), (26, 2.66), (52, 336.73)],[(28, 14.25), (26, 1.8), (66, 875.19)],[(35, 45.55),(32, 36.58),(70, 1343.63)],[(42, 122.0),(27, 0.01), (47, 135.78)],[(43, 246.24), (35, 48.1),(65, 480.55)],[(36, 15.52), (34, 21.79), (82, 2538.18)],[(33, 12.61), (32, 4.22),(64, 635.52)], [(35, 13.95), (33, 5.61), (98, 2616.03)],[(44, 125.88),(36, 20.44), (98, 3350.98)],[(35, 1.46), (34, 3.33), (97, 2613.92)], [(47, 111.54), (41, 3.23), (81, 1854.73)],[(48, 129.45), (42, 51.52), (73, 1075.38)],[(50, 78.81), (41, 2.09), (52, 17.57)], [(57, 260.46), (54, 101.08), (71, 1171.6)],[(46, 80.49),(38, 0.36), (75, 269.97)],[(42, 8.78), (40, 1.79), (93, 2767.85)],[(41, 1.34), (40, 0.95), (50, 39.88)],[(54, 53.46), (47, 28.57), (75, 548.68)], [(54, 162.24), (46, 0.28), (53, 18.23)],[(72, 437.49), (47, 10.08), (59, 141.86)],[(60, 116.23), (54, 95.06), (98, 2984.83)], [(47, 2.14), (46, 1.56), (91, 807.39)],[(49, 15.51), (47, 3.68), (58, 79.93)],[(67, 65.48), (57, 27.5), (52, 22.68)],[(61, 172.64), (56, 49.31), (50, 2.82)],[(60, 66.44), (59, 34.52), (99, 2564.12)], [(56, 10.89), (50, 0.51), (78, 53.79)],[(55, 20.1), (53, 1.38), (85, 251.76)],[(60, 73.79),(59, 23.67),(98, 2110.67)], [(66, 123.03), (64, 102.41), (94, 1471.8)],[(67, 88.35),(56, 4.33), (72, 22.85)],[(73, 238.61), (59, 24.3), (88, 967.59)],[(64, 60.8), (57, 2.13), (84, 86.09)],[(61, 11.06), (57, 0.02), (76, 197.03)], [(60, 7.01), (58, 0.46), (86, 701.09)],[(65, 34.32), (64, 29.85), (83, 556.7)],[(71, 0.67), (60, 0.72), (90, 820.66)],[(67, 1.63), (65, 4.76), (76, 48.03)],[(64, 4.88), (63, 0.95), (98, 1057.59)], [(76, 38.43), (64, 2.94), (91, 132.23)],[(75, 56.34), (72, 70.08), (66, 4.43)],[(76, 11.98), (65, 0.3), (80, 47.73)],[(73, 33.23), (66, 0.64), (94, 594.93)],[(73, 37.53), (68, 2.66), (98, 395.63)], [(70, 0.98), (68, 0.09), (82, 153.53)],[(71, 1.66), (70, 3.35), (94, 232.1)],[(73, 8.99), (70, 0.06), (99, 247.8)],[(73, 8.37), (72, 1.5), (76, 27.18)],[(91, 284.64), (74, 8.86), (89, 104.5)], [(92, 133.06), (84, 102.77), (76, 15.32)],[(90, 243.0), (76, 1.4), (83, 52.22)],[(78, 8.08), (76, 0.52), (81, 1.07)],[(77, 1.19), (76, 0.81), (92, 68.53)],[(78, 2.36), (77, 0.45), (85, 13.18)], [(86, 64.32), (78, 0.98), (80, 8.94)],[(81, 2.59), (98, 355.9)],[(91, 22.35), (85, 1.45), (81, 0.09)],[(98, 264.34), (88, 28.78), (92, 121.87)],[(92, 99.89), (89, 39.52), (94, 99.78)],[(93, 11.99), (88, 28.05), (91, 47.44)],[(88, 5.78), (86, 8.75), (94, 114.95)], [(98, 121.05), (94, 30.41), (89, 19.14)],[(89, 4.9), (87, 2.66), (97, 94.51)],[(97, 85.09)],[(92, 21.23), (91, 11.14), (88, 0.21)], [(98, 6.12), (91, 6.83), (93, 1.31)],[(99, 82.12), (97, 36.97)], [(99, 50.99), (94, 10.47), (96, 23.53)],[(97, 22.17)],[(99, 34.68), (97, 11.24), (96, 10.83)],[(99, 32.77), (97, 6.71), (94, 0.19)], [(96, 2.03), (98, 5.91)],[(99, 0.27), (98, 6.17)],[(99, 5.87), (97, 0.43), (98, 3.32)],[(98, 0.3)],[(99, 0.33)],[(99, 0.0)]]))" 281 | ] 282 | }, 283 | { 284 | "cell_type": "markdown", 285 | "metadata": {}, 286 | "source": [ 287 | "The cost from node 68 to node 71 is 1.66 and so on." 288 | ] 289 | }, 290 | { 291 | "cell_type": "markdown", 292 | "metadata": {}, 293 | "source": [ 294 | "## Solutions" 295 | ] 296 | }, 297 | { 298 | "cell_type": "markdown", 299 | "metadata": {}, 300 | "source": [ 301 | "### Exercise 1" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": 4, 307 | "metadata": { 308 | "hide-output": false 309 | }, 310 | "outputs": [ 311 | { 312 | "name": "stdout", 313 | "output_type": "stream", 314 | "text": [ 315 | "node 0\n", 316 | "node 8\n", 317 | "node 11\n", 318 | "node 18\n", 319 | "node 23\n", 320 | "node 33\n", 321 | "node 41\n", 322 | "node 53\n", 323 | "node 56\n", 324 | "node 57\n", 325 | "node 60\n", 326 | "node 67\n", 327 | "node 70\n", 328 | "node 73\n", 329 | "node 76\n", 330 | "node 85\n", 331 | "node 87\n", 332 | "node 88\n", 333 | "node 93\n", 334 | "node 94\n", 335 | "node 96\n", 336 | "node 97\n", 337 | "node 98\n", 338 | "node 99\n", 339 | "Cost: 160.55\n" 340 | ] 341 | } 342 | ], 343 | "source": [ 344 | "function update_J!(J, graph)\n", 345 | " next_J = Dict()\n", 346 | " for node in keys(graph)\n", 347 | " if node == 99\n", 348 | " next_J[node] = 0\n", 349 | " else\n", 350 | " next_J[node] = minimum(cost + J[dest] for (dest, cost) in graph[node])\n", 351 | " end\n", 352 | " end\n", 353 | " return next_J\n", 354 | "end\n", 355 | "\n", 356 | "function print_best_path(J, graph)\n", 357 | " sum_costs = 0.0\n", 358 | " current_location, destination = extrema(keys(graph))\n", 359 | " while current_location != destination\n", 360 | " println(\"node $current_location\")\n", 361 | " running_min = 1e10\n", 362 | " minimizer_dest = Inf\n", 363 | " minimizer_cost = 1e10\n", 364 | " for (dest, cost) in graph[current_location]\n", 365 | " cost_of_path = cost + J[dest]\n", 366 | " if cost_of_path < running_min\n", 367 | " running_min = cost_of_path\n", 368 | " minimizer_cost = cost\n", 369 | " minimizer_dest = dest\n", 370 | " end\n", 371 | " end\n", 372 | "\n", 373 | " current_location = minimizer_dest\n", 374 | " sum_costs += minimizer_cost\n", 375 | " end\n", 376 | "\n", 377 | " sum_costs = round(sum_costs, digits = 2)\n", 378 | "\n", 379 | " println(\"node $destination\\nCost: $sum_costs\")\n", 380 | "end\n", 381 | "\n", 382 | "J = Dict((node => Inf) for node in keys(graph))\n", 383 | "\n", 384 | "while true\n", 385 | " next_J = update_J!(J, graph)\n", 386 | " if next_J == J\n", 387 | " break\n", 388 | " else\n", 389 | " J = next_J\n", 390 | " end\n", 391 | "end\n", 392 | "\n", 393 | "print_best_path(J, graph)" 394 | ] 395 | } 396 | ], 397 | "metadata": { 398 | "date": 1591310617.4229577, 399 | "download_nb": 1, 400 | "download_nb_path": "https://julia.quantecon.org/", 401 | "filename": "short_path.rst", 402 | "filename_with_path": "dynamic_programming/short_path", 403 | "kernelspec": { 404 | "display_name": "Julia 1.4.2", 405 | "language": "julia", 406 | "name": "julia-1.4" 407 | }, 408 | "language_info": { 409 | "file_extension": ".jl", 410 | "mimetype": "application/julia", 411 | "name": "julia", 412 | "version": "1.4.2" 413 | }, 414 | "title": "Shortest Paths" 415 | }, 416 | "nbformat": 4, 417 | "nbformat_minor": 2 418 | } 419 | -------------------------------------------------------------------------------- /zreferences.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "# References\n", 16 | "\n", 17 | "\n", 18 | "\\[Aiy94\\] S Rao Aiyagari. Uninsured Idiosyncratic Risk and Aggregate Saving. *The Quarterly Journal of Economics*, 109(3):659–684, 1994.\n", 19 | "\n", 20 | "\n", 21 | "\\[AMSS02\\] S. Rao Aiyagari, Albert Marcet, Thomas J. Sargent, and Juha Seppala. Optimal Taxation without State-Contingent Debt. *Journal of Political Economy*, 110(6):1220–1254, December 2002.\n", 22 | "\n", 23 | "\n", 24 | "\\[AM05\\] D. B. O. Anderson and J. B. Moore. *Optimal Filtering*. Dover Publications, 2005.\n", 25 | "\n", 26 | "\n", 27 | "\\[AHMS96\\] E. W. Anderson, L. P. Hansen, E. R. McGrattan, and T. J. Sargent. Mechanics of Forming and Estimating Dynamic Linear Economies. In *Handbook of Computational Economics*. Elsevier, vol 1 edition, 1996.\n", 28 | "\n", 29 | "\n", 30 | "\\[Are08\\] Cristina Arellano. Default risk and income fluctuations in emerging economies. *The American Economic Review*, pages 690–712, 2008.\n", 31 | "\n", 32 | "\n", 33 | "\\[AP91\\] Papoulis Athanasios and S Unnikrishna Pillai. *Probability, random variables, and stochastic processes*. Mc-Graw Hill, 1991.\n", 34 | "\n", 35 | "\n", 36 | "\\[BY04\\] Ravi Bansal and Amir Yaron. Risks for the Long Run: A Potential Resolution of Asset Pricing Puzzles. *Journal of Finance*, 59(4):1481–1509, 08 2004. URL: [https://ideas.repec.org/a/bla/jfinan/v59y2004i4p1481-1509.html](https://ideas.repec.org/a/bla/jfinan/v59y2004i4p1481-1509.html), [doi:](https://doi.org/).\n", 37 | "\n", 38 | "\n", 39 | "\\[Bar79\\] Robert J Barro. On the Determination of the Public Debt. *Journal of Political Economy*, 87(5):940–971, 1979.\n", 40 | "\n", 41 | "\n", 42 | "\\[BBZ15\\] Jess Benhabib, Alberto Bisin, and Shenghao Zhu. The wealth distribution in bewley economies with capital income risk. *Journal of Economic Theory*, 159:489–515, 2015.\n", 43 | "\n", 44 | "\n", 45 | "\\[BS79\\] L M Benveniste and J A Scheinkman. On the Differentiability of the Value Function in Dynamic Models of Economics. *Econometrica*, 47(3):727–732, 1979.\n", 46 | "\n", 47 | "\n", 48 | "\\[Ber75\\] Dmitri Bertsekas. *Dynamic Programming and Stochastic Control*. Academic Press, New York, 1975.\n", 49 | "\n", 50 | "\n", 51 | "\\[Bew77\\] Truman Bewley. The permanent income hypothesis: a theoretical formulation. *Journal of Economic Theory*, 16(2):252–292, 1977.\n", 52 | "\n", 53 | "\n", 54 | "\\[Bew86\\] Truman F Bewley. Stationary monetary equilibrium with a continuum of independently fluctuating consumers. In Werner Hildenbran and Andreu Mas-Colell, editors, *Contributions to Mathematical Economics in Honor of Gerard Debreu*, pages 27–102. North-Holland, Amsterdam, 1986.\n", 55 | "\n", 56 | "\n", 57 | "\\[Bis06\\] C. M. Bishop. *Pattern Recognition and Machine Learning*. Springer, 2006.\n", 58 | "\n", 59 | "\n", 60 | "\\[Car01\\] Christopher D Carroll. A Theory of the Consumption Function, with and without Liquidity Constraints. *Journal of Economic Perspectives*, 15(3):23–45, 2001.\n", 61 | "\n", 62 | "\n", 63 | "\\[Car06\\] Christopher D Carroll. The method of endogenous gridpoints for solving dynamic stochastic optimization problems. *Economics Letters*, 91(3):312–320, 2006.\n", 64 | "\n", 65 | "\n", 66 | "\\[Col90\\] Wilbur John Coleman. Solving the Stochastic Growth Model by Policy-Function Iteration. *Journal of Business & Economic Statistics*, 8(1):27–29, 1990.\n", 67 | "\n", 68 | "\n", 69 | "\\[CC08\\] J. D. Cryer and K-S. Chan. *Time Series Analysis*. Springer, 2nd edition edition, 2008.\n", 70 | "\n", 71 | "\n", 72 | "\\[DFH06\\] Steven J Davis, R Jason Faberman, and John Haltiwanger. The flow approach to labor markets: new data sources, micro-macro links and the recent downturn. *Journal of Economic Perspectives*, 2006.\n", 73 | "\n", 74 | "\n", 75 | "\\[Dea91\\] Angus Deaton. Saving and Liquidity Constraints. *Econometrica*, 59(5):1221–1248, 1991.\n", 76 | "\n", 77 | "\n", 78 | "\\[DP94\\] Angus Deaton and Christina Paxson. Intertemporal Choice and Inequality. *Journal of Political Economy*, 102(3):437–467, 1994.\n", 79 | "\n", 80 | "\n", 81 | "\\[DH10\\] Wouter J Den Haan. Comparison of solutions to the incomplete markets model with aggregate uncertainty. *Journal of Economic Dynamics and Control*, 34(1):4–27, 2010.\n", 82 | "\n", 83 | "\n", 84 | "\\[DJ92\\] Raymond J Deneckere and Kenneth L Judd. Cyclical and chaotic behavior in a dynamic equilibrium model, with implications for fiscal policy. *Cycles and chaos in economic equilibrium*, pages 308–329, 1992.\n", 85 | "\n", 86 | "\n", 87 | "\\[DS10\\] Ulrich Doraszelski and Mark Satterthwaite. Computable markov-perfect industry dynamics. *The RAND Journal of Economics*, 41(2):215–243, 2010.\n", 88 | "\n", 89 | "\n", 90 | "\\[DLP13\\] Y E Du, Ehud Lehrer, and A D Y Pauzner. Competitive economy as a ranking device over networks. submitted, 2013.\n", 91 | "\n", 92 | "\n", 93 | "\\[Dud02\\] R M Dudley. *Real Analysis and Probability*. Cambridge Studies in Advanced Mathematics. Cambridge University Press, 2002.\n", 94 | "\n", 95 | "\n", 96 | "\\[EG87\\] Robert F Engle and Clive W J Granger. Co-integration and Error Correction: Representation, Estimation, and Testing. *Econometrica*, 55(2):251–276, 1987.\n", 97 | "\n", 98 | "\n", 99 | "\\[EP95\\] Richard Ericson and Ariel Pakes. Markov-perfect industry dynamics: a framework for empirical work. *The Review of Economic Studies*, 62(1):53–82, 1995.\n", 100 | "\n", 101 | "\n", 102 | "\\[EH01\\] G W Evans and S Honkapohja. *Learning and Expectations in Macroeconomics*. Frontiers of Economic Research. Princeton University Press, 2001.\n", 103 | "\n", 104 | "\n", 105 | "\\[FSTD15\\] Pablo Fajgelbaum, Edouard Schaal, and Mathieu Taschereau-Dumouchel. Uncertainty traps. Technical Report, National Bureau of Economic Research, 2015.\n", 106 | "\n", 107 | "\n", 108 | "\\[Fri56\\] M. Friedman. *A Theory of the Consumption Function*. Princeton University Press, 1956.\n", 109 | "\n", 110 | "\n", 111 | "\\[FF98\\] Milton Friedman and Rose D Friedman. *Two Lucky People*. University of Chicago Press, 1998.\n", 112 | "\n", 113 | "\n", 114 | "\\[Gal37\\] Albert Gallatin. Report on the finances**, november, 1807. In *Reports of the Secretary of the Treasury of the United States, Vol 1*. Government printing office, Washington, DC, 1837.\n", 115 | "\n", 116 | "\n", 117 | "\\[Hal78\\] Robert E Hall. Stochastic Implications of the Life Cycle-Permanent Income Hypothesis: Theory and Evidence. *Journal of Political Economy*, 86(6):971–987, 1978.\n", 118 | "\n", 119 | "\n", 120 | "\\[HM82\\] Robert E Hall and Frederic S Mishkin. The Sensitivity of Consumption to Transitory Income: Estimates from Panel Data on Households. *National Bureau of Economic Research Working Paper Series*, 1982.\n", 121 | "\n", 122 | "\n", 123 | "\\[Ham05\\] James D Hamilton. What’s real about the business cycle? *Federal Reserve Bank of St. Louis Review*, pages 435–452, 2005.\n", 124 | "\n", 125 | "\n", 126 | "\\[HS08\\] L P Hansen and T J Sargent. *Robustness*. Princeton University Press, 2008.\n", 127 | "\n", 128 | "\n", 129 | "\\[HS13\\] L P Hansen and T J Sargent. *Recursive Models of Dynamic Linear Economies*. The Gorman Lectures in Economics. Princeton University Press, 2013.\n", 130 | "\n", 131 | "\n", 132 | "\\[Han07\\] Lars Peter Hansen. Beliefs, Doubts and Learning: Valuing Macroeconomic Risk. *American Economic Review*, 97(2):1–30, May 2007. URL: [https://ideas.repec.org/a/aea/aecrev/v97y2007i2p1-30.html](https://ideas.repec.org/a/aea/aecrev/v97y2007i2p1-30.html), [doi:](https://doi.org/).\n", 133 | "\n", 134 | "\n", 135 | "\\[HHL08\\] Lars Peter Hansen, John C. Heaton, and Nan Li. Consumption Strikes Back? Measuring Long-Run Risk. *Journal of Political Economy*, 116(2):260–302, 04 2008. URL: [https://ideas.repec.org/a/ucp/jpolec/v116y2008i2p260-302.html](https://ideas.repec.org/a/ucp/jpolec/v116y2008i2p260-302.html), [doi:](https://doi.org/).\n", 136 | "\n", 137 | "\n", 138 | "\\[HR87\\] Lars Peter Hansen and Scott F Richard. The Role of Conditioning Information in Deducing Testable. *Econometrica*, 55(3):587–613, May 1987.\n", 139 | "\n", 140 | "\n", 141 | "\\[HS80\\] Lars Peter Hansen and Thomas J Sargent. Formulating and estimating dynamic linear rational expectations models. *Journal of Economic Dynamics and control*, 2:7–46, 1980.\n", 142 | "\n", 143 | "\n", 144 | "\\[HS00\\] Lars Peter Hansen and Thomas J Sargent. Wanting robustness in macroeconomics. *Manuscript, Department of Economics, Stanford University.*, 2000.\n", 145 | "\n", 146 | "\n", 147 | "\\[HS17\\] Lars Peter Hansen and Thomas J. Sargent. *Risk, Uncertainty, and Value*. Princeton University Press, Princeton, New Jersey, 2017.\n", 148 | "\n", 149 | "\n", 150 | "\\[HS09\\] Lars Peter Hansen and Jose A. Scheinkman. Long-term risk: an operator approach. *Econometrica*, 77(1):177–234, 01 2009.\n", 151 | "\n", 152 | "\n", 153 | "\\[HK78\\] J. Michael Harrison and David M. Kreps. Speculative investor behavior in a stock market with heterogeneous expectations. *The Quarterly Journal of Economics*, 92(2):323–336, 1978.\n", 154 | "\n", 155 | "\n", 156 | "\\[HK79\\] J. Michael Harrison and David M. Kreps. Martingales and arbitrage in multiperiod securities markets. *Journal of Economic Theory*, 20(3):381–408, June 1979.\n", 157 | "\n", 158 | "\n", 159 | "\\[HL96\\] John Heaton and Deborah J Lucas. Evaluating the effects of incomplete markets on risk sharing and asset pricing. *Journal of Political Economy*, pages 443–487, 1996.\n", 160 | "\n", 161 | "\n", 162 | "\\[HK85\\] Elhanan Helpman and Paul Krugman. *Market structure and international trade*. MIT Press Cambridge, 1985.\n", 163 | "\n", 164 | "\n", 165 | "\\[HLL96\\] O Hernandez-Lerma and J B Lasserre. *Discrete-Time Markov Control Processes: Basic Optimality Criteria*. Number Vol 1 in Applications of Mathematics Stochastic Modelling and Applied Probability. Springer, 1996.\n", 166 | "\n", 167 | "\n", 168 | "\\[HP92\\] Hugo A Hopenhayn and Edward C Prescott. Stochastic Monotonicity and Stationary Distributions for Dynamic Economies. *Econometrica*, 60(6):1387–1406, 1992.\n", 169 | "\n", 170 | "\n", 171 | "\\[HR93\\] Hugo A Hopenhayn and Richard Rogerson. Job Turnover and Policy Evaluation: A General Equilibrium Analysis. *Journal of Political Economy*, 101(5):915–938, 1993.\n", 172 | "\n", 173 | "\n", 174 | "\\[Hug93\\] Mark Huggett. The risk-free rate in heterogeneous-agent incomplete-insurance economies. *Journal of Economic Dynamics and Control*, 17(5-6):953–969, 1993.\n", 175 | "\n", 176 | "\n", 177 | "\\[Haggstrom02\\] Olle Häggström. *Finite Markov chains and algorithmic applications*. Volume 52. Cambridge University Press, 2002.\n", 178 | "\n", 179 | "\n", 180 | "\\[Janich94\\] K Jänich. *Linear Algebra*. Springer Undergraduate Texts in Mathematics and Technology. Springer, 1994.\n", 181 | "\n", 182 | "\n", 183 | "\\[JYC88\\] Robert J. Shiller John Y. Campbell. The Dividend-Price Ratio and Expectations of Future Dividends and Discount Factors. *Review of Financial Studies*, 1(3):195–228, 1988.\n", 184 | "\n", 185 | "\n", 186 | "\\[Jud90\\] K L Judd. Cournot versus bertrand: a dynamic resolution. Technical Report, Hoover Institution, Stanford University, 1990.\n", 187 | "\n", 188 | "\n", 189 | "\\[Jud85\\] Kenneth L Judd. On the performance of patents. *Econometrica*, pages 567–585, 1985.\n", 190 | "\n", 191 | "\n", 192 | "\\[Kam12\\] Takashi Kamihigashi. Elementary results on solutions to the bellman equation of dynamic programming: existence, uniqueness, and convergence. Technical Report, Kobe University, 2012.\n", 193 | "\n", 194 | "\n", 195 | "\\[Kre88\\] David M. Kreps. *Notes on the Theory of Choice*. Westview Press, Boulder, Colorado, 1988.\n", 196 | "\n", 197 | "\n", 198 | "\\[Kuh13\\] Moritz Kuhn. Recursive Equilibria In An Aiyagari-Style Economy With Permanent Income Shocks. *International Economic Review*, 54:807–835, 2013.\n", 199 | "\n", 200 | "\n", 201 | "\\[LM94\\] A Lasota and M C MacKey. *Chaos, Fractals, and Noise: Stochastic Aspects of Dynamics*. Applied Mathematical Sciences. Springer-Verlag, 1994.\n", 202 | "\n", 203 | "\n", 204 | "\\[LL01\\] Martin Lettau and Sydney Ludvigson. Consumption, Aggregate Wealth, and Expected Stock Returns. *Journal of Finance*, 56(3):815–849, 06 2001.\n", 205 | "\n", 206 | "\n", 207 | "\\[LL04\\] Martin Lettau and Sydney C. Ludvigson. Understanding Trend and Cycle in Asset Values: Reevaluating the Wealth Effect on Consumption. *American Economic Review*, 94(1):276–299, March 2004.\n", 208 | "\n", 209 | "\n", 210 | "\\[LM80\\] David Levhari and Leonard J Mirman. The great fish war: an example using a dynamic cournot-nash solution. *The Bell Journal of Economics*, pages 322–334, 1980.\n", 211 | "\n", 212 | "\n", 213 | "\\[LS18\\] L Ljungqvist and T J Sargent. *Recursive Macroeconomic Theory*. MIT Press, 4 edition, 2018.\n", 214 | "\n", 215 | "\n", 216 | "\\[Luc78\\] Robert E Lucas, Jr. Asset prices in an exchange economy. *Econometrica: Journal of the Econometric Society*, 46(6):1429–1445, 1978.\n", 217 | "\n", 218 | "\n", 219 | "\\[Luc03\\] Robert E Lucas, Jr. Macroeconomic Priorities. *American Economic Review*, 93(1):1–14, March 2003. URL: [https://www.aeaweb.org/articles?id=10.1257/000282803321455133](https://www.aeaweb.org/articles?id=10.1257/000282803321455133).\n", 220 | "\n", 221 | "\n", 222 | "\\[LP71\\] Robert E Lucas, Jr. and Edward C Prescott. Investment under uncertainty. *Econometrica: Journal of the Econometric Society*, pages 659–681, 1971.\n", 223 | "\n", 224 | "\n", 225 | "\\[LS83\\] Robert E Lucas, Jr. and Nancy L Stokey. Optimal Fiscal and Monetary Policy in an Economy without Capital. *Journal of monetary Economics*, 12(3):55–93, 1983.\n", 226 | "\n", 227 | "\n", 228 | "\\[MS89\\] Albert Marcet and Thomas J Sargent. Convergence of Least-Squares Learning in Environments with Hidden State Variables and Private Information. *Journal of Political Economy*, 97(6):1306–1322, 1989.\n", 229 | "\n", 230 | "\n", 231 | "\\[MdRV10\\] V Filipe Martins-da-Rocha and Yiannis Vailakis. Existence and Uniqueness of a Fixed Point for Local Contractions. *Econometrica*, 78(3):1127–1141, 2010.\n", 232 | "\n", 233 | "\n", 234 | "\\[MCWG95\\] A Mas-Colell, M D Whinston, and J R Green. *Microeconomic Theory*. Volume 1. Oxford University Press, 1995.\n", 235 | "\n", 236 | "\n", 237 | "\\[McC70\\] J J McCall. Economics of Information and Job Search. *The Quarterly Journal of Economics*, 84(1):113–126, 1970.\n", 238 | "\n", 239 | "\n", 240 | "\\[MT09\\] S P Meyn and R L Tweedie. *Markov Chains and Stochastic Stability*. Cambridge University Press, 2009.\n", 241 | "\n", 242 | "\n", 243 | "\\[MF02\\] Mario J Miranda and P L Fackler. *Applied Computational Economics and Finance*. Cambridge: MIT Press, 2002.\n", 244 | "\n", 245 | "\n", 246 | "\\[MB54\\] F. Modigliani and R. Brumberg. Utility analysis and the consumption function: An interpretation of cross-section data. In K.K Kurihara, editor, *Post-Keynesian Economics*. 1954.\n", 247 | "\n", 248 | "\n", 249 | "\\[Mut60\\] John F Muth. Optimal properties of exponentially weighted forecasts. *Journal of the american statistical association*, 55(290):299–306, 1960.\n", 250 | "\n", 251 | "\n", 252 | "\\[Nea99\\] Derek Neal. The Complexity of Job Mobility among Young Men. *Journal of Labor Economics*, 17(2):237–261, 1999.\n", 253 | "\n", 254 | "\n", 255 | "\\[Orf88\\] Sophocles J Orfanidis. *Optimum Signal Processing: An Introduction*. McGraw Hill Publishing, New York, New York, 1988.\n", 256 | "\n", 257 | "\n", 258 | "\\[Par99\\] Jonathan A Parker. The Reaction of Household Consumption to Predictable Changes in Social Security Taxes. *American Economic Review*, 89(4):959–973, 1999.\n", 259 | "\n", 260 | "\n", 261 | "\\[Per19\\] Jesse Perla. A model of product awareness and industry life cycles. Working Paper, University of British Columbia, 2019.\n", 262 | "\n", 263 | "\n", 264 | "\\[Put05\\] Martin L Puterman. *Markov decision processes: discrete stochastic dynamic programming*. John Wiley & Sons, 2005.\n", 265 | "\n", 266 | "\n", 267 | "\\[PalS13\\] Jenő Pál and John Stachurski. Fitted value function iteration with probability one contractions. *Journal of Economic Dynamics and Control*, 37(1):251–264, 2013.\n", 268 | "\n", 269 | "\n", 270 | "\\[Rab02\\] Guillaume Rabault. When do borrowing constraints bind? Some new results on the income fluctuation problem. *Journal of Economic Dynamics and Control*, 26(2):217–245, 2002.\n", 271 | "\n", 272 | "\n", 273 | "\\[Ram27\\] F. P. Ramsey. A Contribution to the theory of taxation. *Economic Journal*, 37(145):47–61, 1927.\n", 274 | "\n", 275 | "\n", 276 | "\\[Rei09\\] Michael Reiter. Solving heterogeneous-agent models by projection and perturbation. *Journal of Economic Dynamics and Control*, 33(3):649–665, 2009.\n", 277 | "\n", 278 | "\n", 279 | "\\[Rom05\\] Steven Roman. *Advanced linear algebra*. Volume 3. Springer, 2005.\n", 280 | "\n", 281 | "\n", 282 | "\\[Roz67\\] Y. A. Rozanov. *Stationary Random Processes*. Holden-Day, San Francisco, 1967.\n", 283 | "\n", 284 | "\n", 285 | "\\[Rus96\\] John Rust. Numerical dynamic programming in economics. *Handbook of computational economics*, 1:619–729, 1996.\n", 286 | "\n", 287 | "\n", 288 | "\\[Rya12\\] Stephen P Ryan. The costs of environmental regulation in a concentrated industry. *Econometrica*, 80(3):1019–1061, 2012.\n", 289 | "\n", 290 | "\n", 291 | "\\[Sar87\\] Thomas J Sargent. *Macroeconomic Theory*. Academic Press, New York, 2nd edition, 1987.\n", 292 | "\n", 293 | "\n", 294 | "\\[SE77\\] Jack Schechtman and Vera L S Escudero. Some results on an income fluctuation problem. *Journal of Economic Theory*, 16(2):151–166, 1977.\n", 295 | "\n", 296 | "\n", 297 | "\\[Sch14\\] Jose A. Scheinkman. *Speculation, Trading, and Bubbles*. Columbia University Press, New York, 2014.\n", 298 | "\n", 299 | "\n", 300 | "\\[Sch69\\] Thomas C Schelling. Models of Segregation. *American Economic Review*, 59(2):488–493, 1969.\n", 301 | "\n", 302 | "\n", 303 | "\\[Shi95\\] A N Shiryaev. *Probability*. Graduate Texts in Mathematics. Springer, 2nd edition, 1995.\n", 304 | "\n", 305 | "\n", 306 | "\\[SR14\\] Alexander A. Stepanov and Daniel E. Rose. *From mathematics to generic programming*. Addison-Wesley, 2014. ISBN 978-0-321-94204-3.\n", 307 | "\n", 308 | "\n", 309 | "\\[SLP89\\] N L Stokey, R E Lucas, and E C Prescott. *Recursive Methods in Economic Dynamics*. Harvard University Press, 1989.\n", 310 | "\n", 311 | "\n", 312 | "\\[STY04\\] Kjetil Storesletten, Christopher I Telmer, and Amir Yaron. Consumption and risk sharing over the life cycle. *Journal of Monetary Economics*, 51(3):609–633, 2004.\n", 313 | "\n", 314 | "\n", 315 | "\\[Sun96\\] R K Sundaram. *A First Course in Optimization Theory*. Cambridge University Press, 1996.\n", 316 | "\n", 317 | "\n", 318 | "\\[Tal00\\] Thomas D Tallarini. Risk-sensitive real business cycles. *Journal of Monetary Economics*, 45(3):507–532, June 2000.\n", 319 | "\n", 320 | "\n", 321 | "\\[Tau86\\] George Tauchen. Finite state markov-chain approximations to univariate and vector autoregressions. *Economics Letters*, 20(2):177–181, 1986.\n", 322 | "\n", 323 | "\n", 324 | "\\[VL11\\] Ngo Van Long. Dynamic games in the economics of natural resources: a survey. *Dynamic Games and Applications*, 1(1):115–148, 2011.\n", 325 | "\n", 326 | "\n", 327 | "\\[Wal47\\] Abraham Wald. *Sequential Analysis*. John Wiley and Sons, New York, 1947.\n", 328 | "\n", 329 | "\n", 330 | "\\[Whi63\\] Peter Whittle. *Prediction and regulation by linear least-square methods*. English Univ. Press, 1963.\n", 331 | "\n", 332 | "\n", 333 | "\\[Whi83\\] Peter Whittle. *Prediction and Regulation by Linear Least Squares Methods*. University of Minnesota Press, Minneapolis, Minnesota, 2nd edition, 1983.\n", 334 | "\n", 335 | "\n", 336 | "\\[YS05\\] G Alastair Young and Richard L Smith. *Essentials of statistical inference*. Cambridge University Press, 2005." 337 | ] 338 | } 339 | ], 340 | "metadata": { 341 | "date": 1591310629.8912766, 342 | "download_nb": 1, 343 | "download_nb_path": "https://julia.quantecon.org/", 344 | "filename": "zreferences.rst", 345 | "filename_with_path": "zreferences", 346 | "kernelspec": { 347 | "display_name": "Julia 1.4.2", 348 | "language": "julia", 349 | "name": "julia-1.4" 350 | }, 351 | "language_info": { 352 | "file_extension": ".jl", 353 | "mimetype": "application/julia", 354 | "name": "julia", 355 | "version": "1.4.2" 356 | }, 357 | "title": "References" 358 | }, 359 | "nbformat": 4, 360 | "nbformat_minor": 2 361 | } 362 | -------------------------------------------------------------------------------- /more_julia/version_control.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "\n", 8 | "\n", 9 | "
\n", 10 | " \n", 11 | " \"QuantEcon\"\n", 12 | " \n", 13 | "
" 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "# Git, GitHub, and Version Control" 21 | ] 22 | }, 23 | { 24 | "cell_type": "markdown", 25 | "metadata": {}, 26 | "source": [ 27 | "## Contents\n", 28 | "\n", 29 | "- [Git, GitHub, and Version Control](#Git,-GitHub,-and-Version-Control) \n", 30 | " - [Setup](#Setup) \n", 31 | " - [Basic Objects](#Basic-Objects) \n", 32 | " - [Individual Workflow](#Individual-Workflow) \n", 33 | " - [Collaborative Work](#Collaborative-Work) \n", 34 | " - [Collaboration via Pull Request](#Collaboration-via-Pull-Request) \n", 35 | " - [Additional Resources and Troubleshooting](#Additional-Resources-and-Troubleshooting) \n", 36 | " - [Exercises](#Exercises) " 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "Co-authored with Arnav Sood\n", 44 | "\n", 45 | "An essential part of modern software engineering is using version control.\n", 46 | "\n", 47 | "We use version control because\n", 48 | "\n", 49 | "- Not all iterations on a file are perfect, and you may want to revert changes. \n", 50 | "- We want to be able to see who has changed what and how. \n", 51 | "- We want a uniform version scheme to do this between people and machines. \n", 52 | "- Concurrent editing on code is necessary for collaboration. \n", 53 | "- Version control is an essential part of creating reproducible research. \n", 54 | "\n", 55 | "\n", 56 | "In this lecture, we’ll discuss how to use Git and GitHub." 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "## Setup\n", 64 | "\n", 65 | "1. Make sure you create an account on [GitHub.com](http://github.com/). \n", 66 | " \n", 67 | " - If you are a student, be sure to use the GitHub [Student Developer Pack](https://education.github.com/pack/). \n", 68 | " - Otherwise, see if you qualify for a free [Non-Profit/Academic Plan](https://help.github.com/articles/about-github-education-for-educators-and-researchers/). \n", 69 | " - These come with things like unlimited private repositories, testing support, etc. \n", 70 | " \n", 71 | "1. Install `git` and the GitHub Desktop application. \n", 72 | " \n", 73 | " 1. Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git/). \n", 74 | " 1. Install the [GitHub Desktop](https://desktop.github.com/) application. \n", 75 | " \n", 76 | "1. Optionally (but strongly recommended): On Windows, change the default line-ending by: \n", 77 | "\n", 78 | "1. Opening a Windows/Powershell console, or the “Git Bash” installed in the previous step. \n", 79 | "1. Running the following " 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": { 85 | "hide-output": false 86 | }, 87 | "source": [ 88 | "```text\n", 89 | "git config --global core.eol lf\n", 90 | "git config --global core.autocrlf false\n", 91 | "```\n" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "\n", 99 | "\n", 100 | "\n", 101 | "\n", 102 | "### Git vs. GitHub vs. GitHub Desktop\n", 103 | "\n", 104 | "To understand the relationship\n", 105 | "\n", 106 | "- Git is an infrastructure for versioning and merging files (it is not specific to GitHub and does not even require an online server). \n", 107 | "- GitHub provides an online service to coordinate working with Git repositories, and adds some additional features for managing projects. \n", 108 | "- GitHub Desktop is just one of many GUI-based clients to make Git and GitHub easier to use. \n", 109 | "\n", 110 | "\n", 111 | "Later, you may find yourself using alternatives\n", 112 | "\n", 113 | "- GitHub is the market leader for open source projects and Julia, but there are other options, e.g. [GitLab](https://about.gitlab.com/) and [Bitbucket](https://bitbucket.org). \n", 114 | "- Instead of the GitHub Desktop, you may directly use the Git command line, [GitKraken](https://www.gitkraken.com/), or use the Git functionality built into editors such as [Atom](https://atom.io/) or [VS Code](https://code.visualstudio.com/). \n", 115 | "\n", 116 | "\n", 117 | "Since these lecture notes are intended to provide a minimal path to using the technologies, here we will conflate the workflow of these distinct products." 118 | ] 119 | }, 120 | { 121 | "cell_type": "markdown", 122 | "metadata": {}, 123 | "source": [ 124 | "## Basic Objects" 125 | ] 126 | }, 127 | { 128 | "cell_type": "markdown", 129 | "metadata": {}, 130 | "source": [ 131 | "### Repositories\n", 132 | "\n", 133 | "The fundamental object in GitHub is a *repository* (or “repo”) – this is the master directory for a project.\n", 134 | "\n", 135 | "One example of a repo is the QuantEcon [Expectations.jl](https://github.com/quantecon/expectations.jl/) package.\n", 136 | "\n", 137 | "On the machine, a repo is a normal directory, along with a subdirectory called `.git` which contains the history of changes." 138 | ] 139 | }, 140 | { 141 | "cell_type": "markdown", 142 | "metadata": {}, 143 | "source": [ 144 | "### Commits\n", 145 | "\n", 146 | "GitHub stores history as a sequence of changes to text, called *commits*.\n", 147 | "\n", 148 | "[Here](https://github.com/QuantEcon/lecture-source-jl/commit/ba59c3ea9a0dec10def3f4f3928af5e2827f3b92) is an example of a commit, which revises the style guide in a QuantEcon repo.\n", 149 | "\n", 150 | "In particular, commits have the following features\n", 151 | "\n", 152 | "- An ID (formally, an “SHA-1 hash”) \n", 153 | "- Content (i.e., a before and after state) \n", 154 | "- Metadata (author, timestamp, commit message, etc.) \n", 155 | "\n", 156 | "\n", 157 | "**Note:** It’s crucial to remember that what’s stored in a commit is only the actual changes you make to text.\n", 158 | "\n", 159 | "This is a key reason why git can store long and complicated histories without consuming massive amounts of memory." 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "### Common Files\n", 167 | "\n", 168 | "In addition, each GitHub repository typically comes with a few standard text files\n", 169 | "\n", 170 | "- A `.gitignore` file, which lists files/extensions/directories that GitHub shouldn’t try to track (e.g., LaTeX compilation byproducts). \n", 171 | "- A `README.md` file, which is a Markdown file which GitHub puts on the repository website. \n", 172 | "- A `LICENSE.txt` file, which describes the terms under which the repository’s contents are made available. \n", 173 | "\n", 174 | "\n", 175 | "For an example of all three, see the [Expectations.jl](https://github.com/quantecon/expectations.jl/) repo.\n", 176 | "\n", 177 | "Of these, the `README.md` is the most important, as GitHub will display it as [Markdown](https://guides.github.com/features/mastering-markdown/) when accessing the repository online.\n", 178 | "\n", 179 | "\n", 180 | "" 181 | ] 182 | }, 183 | { 184 | "cell_type": "markdown", 185 | "metadata": {}, 186 | "source": [ 187 | "## Individual Workflow\n", 188 | "\n", 189 | "In this section, we’ll describe how to use GitHub to version your own projects.\n", 190 | "\n", 191 | "Much of this will carry over to the collaborative section." 192 | ] 193 | }, 194 | { 195 | "cell_type": "markdown", 196 | "metadata": {}, 197 | "source": [ 198 | "### Creating a Repository\n", 199 | "\n", 200 | "In general, we will always want to repos for new projects using the following dropdown\n", 201 | "\n", 202 | "\n", 203 | "\n", 204 | " \n", 205 | "We can then configure repository options as such\n", 206 | "\n", 207 | "\n", 208 | "\n", 209 | " \n", 210 | "In this case, we’re making a public repo `github.com/quantecon_user/example_repository`, which will come with a `README.md`, is licensed under the MIT License, and will ignore Julia compilation byproducts.\n", 211 | "\n", 212 | "**Note** This workflow is for creating projects *de novo*; the process for turning existing directories into git repos is a bit more complicated.\n", 213 | "\n", 214 | "In particular, in that case we recommend that you create a new repo via this method, then copy in and commit your files (see below), and then delete the old directory." 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "metadata": {}, 220 | "source": [ 221 | "### Cloning a Repository\n", 222 | "\n", 223 | "The next step is to get this to our local machine\n", 224 | "\n", 225 | "\n", 226 | "\n", 227 | " \n", 228 | "This dropdown gives us a few options\n", 229 | "\n", 230 | "- “Open in Desktop” will call to the GitHub Desktop application that we’ve installed. \n", 231 | "- “Download Zip” will download the directory *without the .git* subdirectory (avoid this option). \n", 232 | "- The copy/paste button next to the link lets us use the command line, i.e. `git clone https://github.com/quanteconuser/example_repository.git`. " 233 | ] 234 | }, 235 | { 236 | "cell_type": "markdown", 237 | "metadata": {}, 238 | "source": [ 239 | "### Making and Managing Changes\n", 240 | "\n", 241 | "Now that we have the repository, we can start working with it.\n", 242 | "\n", 243 | "For example, let’s say that we’ve amended the `README.md` (using our editor of choice), and also added a new file `economics.jl` which we’re still working on.\n", 244 | "\n", 245 | "Returning to GitHub Desktop, we should see something like\n", 246 | "\n", 247 | "\n", 248 | "\n", 249 | " \n", 250 | "To select individual files for commit, we can use the check boxes to the left of each file.\n", 251 | "\n", 252 | "Let’s say you select only the README to commit. Going to the history tab should show you our change\n", 253 | "\n", 254 | "\n", 255 | "\n", 256 | " \n", 257 | "The Julia file is unchanged." 258 | ] 259 | }, 260 | { 261 | "cell_type": "markdown", 262 | "metadata": {}, 263 | "source": [ 264 | "### Pushing to the Server\n", 265 | "\n", 266 | "As of now, this commit lives only on our local machine.\n", 267 | "\n", 268 | "To upload it to the server, you can simply click the “Push Origin” button at the top the screen.\n", 269 | "\n", 270 | "The small “1^” to the right of the text indicates we have one commit to upload." 271 | ] 272 | }, 273 | { 274 | "cell_type": "markdown", 275 | "metadata": {}, 276 | "source": [ 277 | "### Reading and Reverting History\n", 278 | "\n", 279 | "As mentioned, one of the key features of GitHub is the ability to scan through history.\n", 280 | "\n", 281 | "By clicking the “commits” tab on the repo front page,\n", 282 | "we see [this page](https://github.com/quanteconuser/example_repository/commits/master)\n", 283 | "(as an example).\n", 284 | "\n", 285 | "Clicking an individual commit gives us the difference view, (e.g., [example commit](https://github.com/quanteconuser/example_repository/commit/d0b17f5ce0f8742e88da9b604bfed418d6a16884/)).\n", 286 | "\n", 287 | "Sometimes, however, we want to not only inspect what happened before, but reverse the commit.\n", 288 | "\n", 289 | "- If you haven’t made the commit yet, just right-click the file in the “changes” tab and hit “discard changes” to reset the file to the last known commit. \n", 290 | "- If you have made the commit but haven’t pushed to the server yet, go to the “history” tab as above, right click the commit and click “revert this commit.” This will create the inverse commit, shown below. \n", 291 | "\n", 292 | "\n", 293 | "" 294 | ] 295 | }, 296 | { 297 | "cell_type": "markdown", 298 | "metadata": {}, 299 | "source": [ 300 | "### Working across Machines\n", 301 | "\n", 302 | "Generally, you want to work on the same project but across multiple machines (e.g., a home laptop and a lab workstation).\n", 303 | "\n", 304 | "The key is to push changes from one machine, and then to pull changes from the other machine.\n", 305 | "\n", 306 | "Pushing can be done as above.\n", 307 | "\n", 308 | "To pull, simply click pull under the “repository” dropdown at the top of the screen\n", 309 | "\n", 310 | "" 311 | ] 312 | }, 313 | { 314 | "cell_type": "markdown", 315 | "metadata": {}, 316 | "source": [ 317 | "## Collaborative Work" 318 | ] 319 | }, 320 | { 321 | "cell_type": "markdown", 322 | "metadata": {}, 323 | "source": [ 324 | "### Adding Collaborators\n", 325 | "\n", 326 | "First, let’s add a collaborator to the `quanteconuser/example_repository` lecture we created earlier.\n", 327 | "\n", 328 | "We can do this by clicking “settings => collaborators,” as follows\n", 329 | "\n", 330 | "" 331 | ] 332 | }, 333 | { 334 | "cell_type": "markdown", 335 | "metadata": {}, 336 | "source": [ 337 | "### Project Management\n", 338 | "\n", 339 | "GitHub’s website also comes with project management tools to coordinate work between people.\n", 340 | "\n", 341 | "The main one is an *issue*, which we can create from the issues tab.\n", 342 | "\n", 343 | "You should see something like this\n", 344 | "\n", 345 | "\n", 346 | "\n", 347 | " \n", 348 | "Let’s unpack the different components\n", 349 | "\n", 350 | "- The *assignees* dropdown lets you select people tasked to work on the issue. \n", 351 | "- The *labels* dropdown lets you tag the issue with labels visible from the issues page, such as “high priority” or “feature request”. \n", 352 | "- It’s possible to tag other issues and collaborators (including in different repos) by linking to them in the comments – this is part of what’s called *GitHub-Flavored Markdown*. \n", 353 | "\n", 354 | "\n", 355 | "For an example of an issue, see [here](https://github.com/quanteconuser/example_repository/issues/1).\n", 356 | "\n", 357 | "You can see open issues at a glance from the general issues tab\n", 358 | "\n", 359 | "\n", 360 | "\n", 361 | " \n", 362 | "The checkboxes are common in GitHub to manage project tasks." 363 | ] 364 | }, 365 | { 366 | "cell_type": "markdown", 367 | "metadata": {}, 368 | "source": [ 369 | "### Reviewing Code\n", 370 | "\n", 371 | "There are a few different ways to review people’s code in GitHub\n", 372 | "\n", 373 | "- Whenever people push to a project you’re working on, you’ll receive an email notification. \n", 374 | "- You can also review individual line items or commits by opening commits in the difference view as [above](https://github.com/quanteconuser/example_repository/commit/d0b17f5ce0f8742e88da9b604bfed418d6a16884/). \n", 375 | "\n", 376 | "\n", 377 | "\n", 378 | "\n", 379 | " \n", 380 | "\n", 381 | "" 382 | ] 383 | }, 384 | { 385 | "cell_type": "markdown", 386 | "metadata": {}, 387 | "source": [ 388 | "### Merge Conflicts\n", 389 | "\n", 390 | "Any project management tool needs to figure out how to reconcile conflicting changes between people.\n", 391 | "\n", 392 | "In GitHub, this event is called a “merge conflict,” and occurs whenever people make conflicting changes to the same *line* of code.\n", 393 | "\n", 394 | "Note that this means that two people touching the same file is OK, so long as the differences are compatible.\n", 395 | "\n", 396 | "A common use case is when we try to push changes to the server, but someone else has pushed conflicting changes.\n", 397 | "\n", 398 | "GitHub will give us the following window\n", 399 | "\n", 400 | "\n", 401 | "\n", 402 | " \n", 403 | "- The warning symbol next to the file indicates the existence of a merge conflict. \n", 404 | "- The viewer tries to show us the discrepancy (I changed the word repository to repo, but someone else tried to change it to “repo” with quotes). \n", 405 | "\n", 406 | "\n", 407 | "To fix the conflict, we can go into a text editor (such as Atom)\n", 408 | "\n", 409 | "\n", 410 | "\n", 411 | " \n", 412 | "Let’s say we click the first “use me” (to indicate that my changes should win out), and then save the file.\n", 413 | "\n", 414 | "Returning to GitHub Desktop gives us a pre-formed commit to accept\n", 415 | "\n", 416 | "\n", 417 | "\n", 418 | " \n", 419 | "Clicking “commit to master” will let us push and pull from the server as normal." 420 | ] 421 | }, 422 | { 423 | "cell_type": "markdown", 424 | "metadata": {}, 425 | "source": [ 426 | "## Collaboration via Pull Request\n", 427 | "\n", 428 | "One of the defining features of GitHub is that it is the dominant platform for *open source* code, which anyone can access and use.\n", 429 | "\n", 430 | "However, while anyone can make a copy of the source code, not everyone has access to modify the particular version stored on GitHub.\n", 431 | "\n", 432 | "A maintainer (i.e. someone with “write” access to directly modify a repository)\n", 433 | "might consider different contributions and “merge” the changes into the main\n", 434 | "repository if the changes meet their criteria.\n", 435 | "\n", 436 | "A *pull request* (“PR”) allows **any** outsiders to suggest changes to open source repositories.\n", 437 | "\n", 438 | "A PR requests the project maintainer to merge (“pull”) changes you’ve worked on into their repository.\n", 439 | "\n", 440 | "There are a few different workflows for creating and handling PRs, which we’ll walk through below.\n", 441 | "\n", 442 | "**Note:** If the changes are for a Julia Package, you will need to follow a different workflow – described in the [testing lecture](testing.html).\n", 443 | "\n", 444 | "\n", 445 | "" 446 | ] 447 | }, 448 | { 449 | "cell_type": "markdown", 450 | "metadata": {}, 451 | "source": [ 452 | "### Quick Fixes\n", 453 | "\n", 454 | "GitHub’s website provides an online editor for quick and dirty changes, such as fixing typos in documentation.\n", 455 | "\n", 456 | "To use it, open a file in GitHub and click the small pencil to the upper right\n", 457 | "\n", 458 | "\n", 459 | "\n", 460 | " \n", 461 | "Here, we’re trying to add the QuantEcon link to the Julia project’s `README` file.\n", 462 | "\n", 463 | "After making our changes, we can then describe and propose them for review by maintainers.\n", 464 | "\n", 465 | "But what if we want to make more in-depth changes?\n", 466 | "\n", 467 | "\n", 468 | "" 469 | ] 470 | }, 471 | { 472 | "cell_type": "markdown", 473 | "metadata": {}, 474 | "source": [ 475 | "### No-Access Case\n", 476 | "\n", 477 | "A common problem is when we don’t have write access (i.e. we can’t directly modify) the repo in question.\n", 478 | "\n", 479 | "In that case, click the “Fork” button that lives in the top-right of every repo’s main page\n", 480 | "\n", 481 | "\n", 482 | "\n", 483 | " \n", 484 | "This will copy the repo into your own GitHub account.\n", 485 | "\n", 486 | "For example, [this repo](https://github.com/ubcecon/example_repository) is a fork of our original [git setup](https://github.com/quanteconuser/example_repository/).\n", 487 | "\n", 488 | "Clone this fork to our desktop and work with it in exactly the same way as we would a repo we own\n", 489 | "(as the fork is in your account, you now have write access).\n", 490 | "\n", 491 | "That is, click the “clone” button on our fork\n", 492 | "\n", 493 | "\n", 494 | "\n", 495 | " \n", 496 | "You’ll see a new repo with the same name but different URL in your GitHub Desktop repo list, along with a special icon to indicate that it’s a fork\n", 497 | "\n", 498 | "\n", 499 | "\n", 500 | " \n", 501 | "Commit some changes by selecting the files and writing a commit message\n", 502 | "\n", 503 | "\n", 504 | "\n", 505 | " \n", 506 | "And push by using the dropdown\n", 507 | "\n", 508 | "\n", 509 | "\n", 510 | " \n", 511 | "Below, for example, we’ve committed and pushed some changes to the fork that we want to upstream into the main repo\n", 512 | "\n", 513 | "\n", 514 | "\n", 515 | " \n", 516 | "We should make sure that these changes are on the server (which we can get to by going to the [fork](https://github.com/ubcecon/example_repository) and clicking “commits”)\n", 517 | "\n", 518 | "\n", 519 | "\n", 520 | " \n", 521 | "Next, go to the pull requests menu and click “New Pull Request”.\n", 522 | "\n", 523 | "You’ll see something like this\n", 524 | "\n", 525 | "\n", 526 | "\n", 527 | " \n", 528 | "This gives us a quick overview of the commits we want to merge in, as well as the overall differences.\n", 529 | "\n", 530 | "Hit create and then click through the following form.\n", 531 | "\n", 532 | "This opens a page like this on the main repo\n", 533 | "\n", 534 | "\n", 535 | "\n", 536 | " \n", 537 | "The key pieces are\n", 538 | "\n", 539 | "- A list of the commits we’re proposing. \n", 540 | "- A list of reviewers, who can approve or modify our changes. \n", 541 | "- Labels, Markdown space, assignees, and the ability to tag other git issues and PRs, just as with issues. \n", 542 | "\n", 543 | "\n", 544 | "Here’s an [example pull request](https://github.com/quanteconuser/example_repository/pull/3).\n", 545 | "\n", 546 | "To edit a PR, simply push changes to the fork you cloned to your desktop.\n", 547 | "\n", 548 | "For example, let’s say we commit a new change to the README *after* we create the PR\n", 549 | "\n", 550 | "\n", 551 | "\n", 552 | " \n", 553 | "After pushing to the server, the change is reflected on the PR [page](https://github.com/quanteconuser/example_repository/pull/3)\n", 554 | "\n", 555 | "\n", 556 | "\n", 557 | " \n", 558 | "That is, creating a pull request is not like bundling up your changes and delivering them, but rather like opening an *ongoing connection* between two repositories, that is only severed when the PR is closed or merged." 559 | ] 560 | }, 561 | { 562 | "cell_type": "markdown", 563 | "metadata": {}, 564 | "source": [ 565 | "### Write Access Case\n", 566 | "\n", 567 | "As you become more familiar with GitHub, and work on larger projects, you will find yourself making PRs even when it isn’t strictly required.\n", 568 | "\n", 569 | "If you are a maintainer of the repo (e.g. you created it or are a collaborator) then you don’t need to create a fork, but will rather work with a *git branch*.\n", 570 | "\n", 571 | "Branches in git represent parallel development streams (i.e., sequences of commits) that the PR is trying to merge.\n", 572 | "\n", 573 | "First, load the repo in GitHub Desktop and use the branch dropdown\n", 574 | "\n", 575 | "\n", 576 | "\n", 577 | " \n", 578 | "Click “New Branch” and choose an instructive name (make sure there are no spaces or special characters).\n", 579 | "\n", 580 | "This will “check out” a new branch with the same history as the old one (but new commits will be added only to this branch).\n", 581 | "\n", 582 | "We can see the active branch in the top dropdown\n", 583 | "\n", 584 | "\n", 585 | "\n", 586 | " \n", 587 | "For example, let’s say we add some stuff to the Julia code file and commit it\n", 588 | "\n", 589 | "\n", 590 | "\n", 591 | " \n", 592 | "To put this branch (with changes) on the server, we simply need to click “Publish Branch”.\n", 593 | "\n", 594 | "Navigating to the [repo page](https://github.com/quanteconuser/example_repository), we will see a suggestion about a new branch\n", 595 | "\n", 596 | "\n", 597 | "\n", 598 | " \n", 599 | "At which point the process of creating a PR is identical to the previous case." 600 | ] 601 | }, 602 | { 603 | "cell_type": "markdown", 604 | "metadata": {}, 605 | "source": [ 606 | "### Julia Package Case\n", 607 | "\n", 608 | "One special case is when the repo in question is actually a Julia project or package.\n", 609 | "\n", 610 | "We cover that (along with package workflow in general) in the [testing lecture](testing.html)." 611 | ] 612 | }, 613 | { 614 | "cell_type": "markdown", 615 | "metadata": {}, 616 | "source": [ 617 | "## Additional Resources and Troubleshooting\n", 618 | "\n", 619 | "You may want to go beyond the scope of this tutorial when working with GitHub.\n", 620 | "\n", 621 | "For example, perhaps you run into a bug, or you’re working with a setup that doesn’t have GitHub Desktop installed.\n", 622 | "\n", 623 | "Here are some resources to help\n", 624 | "\n", 625 | "- Kate Hudson’s excellent [git flight rules](https://github.com/k88hudson/git-flight-rules/), which is a near-exhaustive list of situations you could encounter, and command-line fixes. \n", 626 | "- The GitHub [Learning Lab](https://lab.github.com/), an interactive sandbox environment for git. \n", 627 | "- The docs for forking on [GitHub Desktop](https://help.github.com/desktop/guides/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop/) and [the GitHub Website](https://guides.github.com/activities/forking/). \n", 628 | "\n", 629 | "\n", 630 | "\n", 631 | "" 632 | ] 633 | }, 634 | { 635 | "cell_type": "markdown", 636 | "metadata": {}, 637 | "source": [ 638 | "### Command-Line Basics\n", 639 | "\n", 640 | "Git also comes with a set of command-line tools.\n", 641 | "\n", 642 | "They’re optional, but many people like using them.\n", 643 | "\n", 644 | "Furthermore, in some environments (e.g. JupyterHub installations) you may only have access to the command line.\n", 645 | "\n", 646 | "- On Windows, downloading `git` will have installed a program called `git bash`, which installs these tools along with a general Linux-style shell. \n", 647 | "- On Linux/MacOS, these tools are integrated into your usual terminal. \n", 648 | "\n", 649 | "\n", 650 | "To open the terminal in a directory, either right click and hit “open git bash” (in Windows), or use Linux commands like `cd` and `ls` to navigate.\n", 651 | "\n", 652 | "See [here](https://www.git-tower.com/learn/git/ebook/en/command-line/appendix/command-line-101) for a short introduction to the command line.\n", 653 | "\n", 654 | "As above, you can clone by grabbing the repo URL (say, GitHub’s [site-policy repo](https://github.com/github/site-policy/)) and running `git clone https://github.com/github/site-policy.git`.\n", 655 | "\n", 656 | "This won’t be connected to your GitHub Desktop, so you’d need to use it manually (`File => Add Local Repository`) or drag-and-drop from the file explorer onto the GitHub Desktop\n", 657 | "\n", 658 | "\n", 659 | "\n", 660 | " \n", 661 | "From here, you can get the latest files on the server by `cd`-ing into the directory and running `git pull`.\n", 662 | "\n", 663 | "When you `pull` from the server, it will never overwrite your modified files, so it is impossible to lose local changes.\n", 664 | "\n", 665 | "Instead, to do a hard reset of all files and overwrite any of your local changes, you can run `git reset --hard origin/master`." 666 | ] 667 | }, 668 | { 669 | "cell_type": "markdown", 670 | "metadata": {}, 671 | "source": [ 672 | "## Exercises" 673 | ] 674 | }, 675 | { 676 | "cell_type": "markdown", 677 | "metadata": {}, 678 | "source": [ 679 | "### Exercise 1a\n", 680 | "\n", 681 | "Follow the instructions to create a [new repository](#new-repo-workflow) for one of your GitHub accounts.\n", 682 | "In this repository\n", 683 | "\n", 684 | "- Take the code from one of your previous assignments, such as [Newton’s method](../getting_started_julia/julia_by_example.html#jbe-ex8a) in [Introductory Examples](../getting_started_julia/julia_by_example.html) (either as a `.jl` file or a Jupyter notebook). \n", 685 | "- Put in a `README.md` with some text. \n", 686 | "- Put in a `.gitignore` file, ignoring the Jupyter files `.ipynb_checkpoints` and the project files, `.projects`. " 687 | ] 688 | }, 689 | { 690 | "cell_type": "markdown", 691 | "metadata": {}, 692 | "source": [ 693 | "### Exercise 1b\n", 694 | "\n", 695 | "Pair-up with another student who has done Exercise 1a and find out their GitHub ID, and each do the following\n", 696 | "\n", 697 | "- Add the GitHub ID as a collaborators on your repository. \n", 698 | "- Clone the repositories to your local desktop. \n", 699 | "- Assign each other an issue. \n", 700 | "- Submit a commit from GitHub Desktop which references the issue by number. \n", 701 | "- Comment on the commits. \n", 702 | "- Ensure you can run their code without any modifications. " 703 | ] 704 | }, 705 | { 706 | "cell_type": "markdown", 707 | "metadata": {}, 708 | "source": [ 709 | "### Exercise 1c\n", 710 | "\n", 711 | "Pair-wise with the results of Exercise 1b examine a merge-conflict by editing the `README.md` file for your repository that you have both setup as collaborators.\n", 712 | "\n", 713 | "Start by ensuring there are multiple lines in the file so that some changes may have conflicts, and some may not.\n", 714 | "\n", 715 | "- Clone the repository to your local desktops. \n", 716 | "- Modify **different** lines of code in the file and both commit and push to the server (prior to pulling from each other)–and see how it merges things “automatically”. \n", 717 | "- Modify **the same** line of code in the file, and deal with the [merge conflict](#merge-conflict). " 718 | ] 719 | }, 720 | { 721 | "cell_type": "markdown", 722 | "metadata": {}, 723 | "source": [ 724 | "### Exercise 2a\n", 725 | "\n", 726 | "Just using GitHub’s [web interface](#web-interface), submit a Pull Request for a simple change of documentation to a public repository.\n", 727 | "\n", 728 | "The easiest may be to submit a PR for a typo in the source repository for these notes, i.e. `https://github.com/QuantEcon/lecture-source-jl`.\n", 729 | "\n", 730 | "Note: The source for that repository is in `.rst` files, but you should be able to find spelling mistakes/etc. without much effort." 731 | ] 732 | }, 733 | { 734 | "cell_type": "markdown", 735 | "metadata": {}, 736 | "source": [ 737 | "### Exercise 2b\n", 738 | "\n", 739 | "Following the [instructions](#fork-workflow) for forking and cloning a public repository to your local desktop, submit a Pull Request to a public repository.\n", 740 | "\n", 741 | "Again, you could submit it for a typo in the source repository for these notes, i.e. `https://github.com/QuantEcon/lecture-source-jl`, but you are also encouraged to instead look for a small change that could help the documentation in another repository.\n", 742 | "\n", 743 | "If you are ambitious, then go to the Exercise Solutions for one of the Exercises in these lecture notes and submit a PR for your own modified version (if you think it is an improvement!)." 744 | ] 745 | } 746 | ], 747 | "metadata": { 748 | "date": 1591310624.5837202, 749 | "download_nb": 1, 750 | "download_nb_path": "https://julia.quantecon.org/", 751 | "filename": "version_control.rst", 752 | "filename_with_path": "more_julia/version_control", 753 | "kernelspec": { 754 | "display_name": "Julia 1.4.2", 755 | "language": "julia", 756 | "name": "julia-1.4" 757 | }, 758 | "language_info": { 759 | "file_extension": ".jl", 760 | "mimetype": "application/julia", 761 | "name": "julia", 762 | "version": "1.4.2" 763 | }, 764 | "title": "Git, GitHub, and Version Control" 765 | }, 766 | "nbformat": 4, 767 | "nbformat_minor": 2 768 | } 769 | --------------------------------------------------------------------------------