Created
September 4, 2019 15:08
-
-
Save boturon/f40960d4d49cd864f6e8f6fa2dc093a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "# Solow-Swan Model" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import matplotlib.pyplot as plt\n", | |
| "import numpy as np\n", | |
| "import ipywidgets as widgets\n", | |
| "from ipywidgets import interact\n", | |
| "from IPython.display import display" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 39, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "def plot(ΔA,Δs,Δδ,Δn):\n", | |
| " \n", | |
| " A,s,δ,n=3,0.5,0.5,0.05\n", | |
| " k = np.linspace(0,10, 100)[1:]\n", | |
| " \n", | |
| " # Graph\n", | |
| " f, ax = plt.subplots(nrows=1, ncols=1, figsize=(6,6))\n", | |
| " ## Constant\n", | |
| " ax.plot(k,A*s*(1/k),color='k')\n", | |
| " ax.axhline(s*δ+n, color='k')\n", | |
| " ax.axvline((A*s)/(s*δ+n), color='k', linestyle=\":\")\n", | |
| " ax.scatter((A*s)/(s*δ+n),s*δ+n, color='k')\n", | |
| " ## Changing\n", | |
| " ax.plot(k,(A+ΔA)*(s+Δs)*(1/k),color='r')\n", | |
| " ax.axhline((s+Δs)*(δ+Δδ)+(n+Δn), color='r')\n", | |
| " ax.axvline(((A+ΔA)*(s+Δs))/((s+Δs)*(δ+Δδ)+(n+Δn)), color='r', linestyle=\":\")\n", | |
| " ax.scatter(((A+ΔA)*(s+Δs))/((s+Δs)*(δ+Δδ)+(n+Δn)),(s+Δs)*(δ+Δδ)+(n+Δn), color='r')\n", | |
| " \n", | |
| " ## Aux\n", | |
| " ax.set_title(\"Solow-Swan Model\")\n", | |
| " ax.set_ylabel(\"Determinants of Δk/k\")\n", | |
| " ax.set_xlabel(\"Capital per Worker (k=K/L)\")\n", | |
| " ax.set_xlim(k[0], k[-1]); ax.set_ylim(0,1)\n", | |
| " ax.grid(); plt.tight_layout()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 40, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "application/vnd.jupyter.widget-view+json": { | |
| "model_id": "ff66058d0fbe417fb6685c040e9efcd9", | |
| "version_major": 2, | |
| "version_minor": 0 | |
| }, | |
| "text/plain": [ | |
| "interactive(children=(IntSlider(value=0, description='ΔA', max=2, min=-2), FloatSlider(value=0.0, description=…" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "interact(plot, ΔA=(-2,2,1),Δs=(-0.5,0.5,0.05),Δδ=(-0.5,0.5,0.05),Δn=(-0.05,0.05,0.01));" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "<br>" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.3" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment