Skip to content

Commit

Permalink
Updating examples
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDowney committed Sep 2, 2024
1 parent 3033f77 commit 9f1cd31
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions examples/salmon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -141,7 +141,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -161,16 +161,16 @@
"source": [
"## Modeling changes\n",
"\n",
"To see how the population changes from year-to-year, I'll use `diff` to compute the absolute difference between each year and the next.\n"
"To see how the population changes from year-to-year, I'll use `diff` to compute the absolute difference between each year and the next and `shift` to align the changes with the year they happened."
]
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"abs_diffs = pop_series.diff()\n",
"abs_diffs = pop_series.diff().shift(-1)\n",
"abs_diffs"
]
},
Expand All @@ -183,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -195,12 +195,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"These relative differences are observed annual net growth rates. So let's drop the `0` and save them."
"These relative differences are observed annual net growth rates.\n",
"So let's drop the `NaN` and save them."
]
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -217,7 +218,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -237,7 +238,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -256,7 +257,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -276,7 +277,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -292,7 +293,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -308,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -341,7 +342,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -357,7 +358,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -370,8 +371,7 @@
" \"\"\"\n",
" for i in range(iters):\n",
" results = run_simulation(system, update_func)\n",
" results.plot(color='gray', label='_nolegend', \n",
" linewidth=1, alpha=0.3)"
" results.plot(color='gray', label='', linewidth=1, alpha=0.3)"
]
},
{
Expand All @@ -385,7 +385,7 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -414,7 +414,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -432,7 +432,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -448,7 +448,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -464,7 +464,7 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -481,7 +481,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -500,7 +500,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -516,7 +516,7 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -532,7 +532,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -567,7 +567,7 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -585,7 +585,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -601,7 +601,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -617,7 +617,7 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -633,7 +633,7 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -649,7 +649,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -665,7 +665,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -689,7 +689,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 9f1cd31

Please sign in to comment.