Skip to content

Commit

Permalink
Merge pull request #604 from sbenthall/i602-ex-cleanup
Browse files Browse the repository at this point in the history
Examples cleanup
  • Loading branch information
llorracc authored Mar 30, 2020
2 parents 32119d8 + 300b3f0 commit 9cef11f
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 118 deletions.
62 changes: 46 additions & 16 deletions examples/ConsumptionSaving/example_ConsGenIncProcessModel.ipynb

Large diffs are not rendered by default.

155 changes: 121 additions & 34 deletions examples/ConsumptionSaving/example_ConsIndShock.ipynb

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions examples/ConsumptionSaving/example_ConsRepAgentModel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"from time import time\n",
"import numpy as np\n",
"from HARK.utilities import plotFuncs\n",
"import HARK.ConsumptionSaving.ConsumerParameters as Params\n",
"from HARK.ConsumptionSaving.ConsIndShockModel import (\n",
" init_idiosyncratic_shocks\n",
")\n",
"\n",
"from HARK.ConsumptionSaving.ConsRepAgentModel import (\n",
" RepAgentConsumerType,\n",
" RepAgentMarkovConsumerType,\n",
Expand All @@ -24,7 +27,7 @@
"outputs": [],
"source": [
"# Make a quick example dictionary\n",
"RA_params = deepcopy(Params.init_idiosyncratic_shocks)\n",
"RA_params = deepcopy(init_idiosyncratic_shocks)\n",
"RA_params[\"DeprFac\"] = 0.05\n",
"RA_params[\"CapShare\"] = 0.36\n",
"RA_params[\"UnempPrb\"] = 0.0\n",
Expand All @@ -40,7 +43,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Solving a representative agent problem took 0.2792696952819824 seconds.\n"
"Solving a representative agent problem took 0.13683128356933594 seconds.\n"
]
},
{
Expand Down Expand Up @@ -77,7 +80,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Simulating a representative agent for 2000 periods took 9.091149091720581 seconds.\n"
"Simulating a representative agent for 2000 periods took 2.0891530513763428 seconds.\n"
]
}
],
Expand Down Expand Up @@ -107,7 +110,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Solving a two state representative agent problem took 0.7686238288879395 seconds.\n"
"Solving a two state representative agent problem took 0.4116179943084717 seconds.\n"
]
},
{
Expand Down Expand Up @@ -151,7 +154,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Simulating a two state representative agent for 2000 periods took 9.762195110321045 seconds.\n"
"Simulating a two state representative agent for 2000 periods took 2.3863446712493896 seconds.\n"
]
}
],
Expand Down Expand Up @@ -194,7 +197,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
136 changes: 105 additions & 31 deletions examples/Gentle-Intro/Gentle-Intro-To-HARK.ipynb

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions examples/Gentle-Intro/Gentle-Intro-To-HARK.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# extension: .py
# format_name: percent
# format_version: '1.2'
# jupytext_version: 1.2.3
# jupytext_version: 1.2.4
# kernelspec:
# display_name: Python 3
# language: python
Expand Down Expand Up @@ -149,12 +149,12 @@
print("This agent's consumption function is defined (consumption is positive) down to m_t = " + str(mMinimum))

# %% [markdown]
# Yikes! Let's take a look at the bottom of the consumption function. In the cell below, set the bounds of the $\texttt{plotFuncs}$ function to display down to the lowest defined value of the consumption function.
# Yikes! Let's take a look at the bottom of the consumption function. In the cell below, the bounds of the $\texttt{plotFuncs}$ function are set to display down to the lowest defined value of the consumption function.

# %%
# YOUR FIRST HANDS-ON EXERCISE!
# Fill in the value for "mPlotBottom" to plot the consumption function from the point where it is zero.
plotFuncs(PFexample.solution[0].cFunc,mPlotBottom,mPlotTop)
plotFuncs(PFexample.solution[0].cFunc,
mMinimum,
mPlotTop)

# %% [markdown]
# ## Changing Agent Parameters
Expand All @@ -171,7 +171,10 @@
NewExample.DiscFac = 0.90
NewExample.solve()
mPlotBottom = mMinimum
plotFuncs([PFexample.solution[0].cFunc,NewExample.solution[0].cFunc],mPlotBottom,mPlotTop)
plotFuncs([PFexample.solution[0].cFunc,
NewExample.solution[0].cFunc],
mPlotBottom,
mPlotTop)

# %% [markdown]
# (Note that you can pass a **list** of functions to $\texttt{plotFuncs}$ as the first argument rather than just a single function. Lists are written inside of [square brackets].)
Expand Down
Loading

0 comments on commit 9cef11f

Please sign in to comment.