Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-haru committed Jul 23, 2024
1 parent fc87b94 commit df91cd3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 19 deletions.
63 changes: 51 additions & 12 deletions 13_random_TFP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## ランダム変数の役割"
Expand Down Expand Up @@ -610,7 +611,8 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## 全要素生産性"
Expand Down Expand Up @@ -1294,7 +1296,8 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 説明"
Expand Down Expand Up @@ -1442,11 +1445,47 @@
"gdp_dict"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"from myst_nb import glue\n",
"var_list = ['gdp','capital','total_hours'] #1\n",
"year_list = [df.index[0].year,df.index[-1].year] #2\n",
"\n",
"gdp_dict = {} #3\n",
"K_dict = {} #4\n",
"H_dict = {} #5\n",
"\n",
"for yr in year_list: #6\n",
" \n",
" cond = ( df.index.year == yr) #7\n",
" mean = df.loc[cond, var_list].mean() #8\n",
" gdp_dict[yr] = mean.iloc[0] #9\n",
" K_dict[yr] = mean.iloc[1] #10\n",
" H_dict[yr] = mean.iloc[2] #11\n",
"\n",
"start_ = gdp_dict[1980]\n",
"end_ = gdp_dict[2023]\n",
"glue(\"start_\", start_, display=False)\n",
"glue(\"end_\", end_, display=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"キー・値の2つの対がある。キー`1980`の値には1980年のGDPの平均が設定されており,同様に,キー`2021`の値には2021年のGDPの平均が設定されている。従って,次のコードで`1980`年の値にアクセスできる。\n",
"キー・値の2つのペアがある。キー{glue:}`start_`の値には{glue:}`start_`年のGDPの平均が設定されており,同様に,もう一つのキー{glue:}`start_`の値には{glue:}`start_`年のGDPの平均が設定されている。従って,次のコードで{glue:}`start_`年の値にアクセスできる。\n",
"```\n",
"gdp_dict[1980]\n",
"```\n",
Expand All @@ -1463,16 +1502,16 @@
"上のコードで`for`ループを使っているが,もし使わなければ次のようなコードになる。\n",
"```\n",
"var_list = ['gdp','capital', 'total_hours']\n",
"mean1980 = df.loc['1980-03-31':'1980-12-31',var_list].mean()\n",
"mean2019 = df.loc['2019-03-31':'2019-12-31',var_list].mean()\n",
"mean1980 = df.loc['1980-01-01':'1980-10-01',var_list].mean()\n",
"mean2019 = df.loc['2019-01-01':'2019-10-01',var_list].mean()\n",
"\n",
"gdp1980 = mean1980[0]\n",
"K1980 = mean1980[1]\n",
"H1980 = mean1980[2]\n",
"gdp1980 = mean1980.iloc[0]\n",
"K1980 = mean1980.iloc[1]\n",
"H1980 = mean1980.iloc[2]\n",
"\n",
"gdp2019 = mean2019[0]\n",
"K2019 = mean2019[1]\n",
"H2019 = mean2019[2]\n",
"gdp2019 = mean2019.iloc[0]\n",
"K2019 = mean2019.iloc[1]\n",
"H2019 = mean2019.iloc[2]\n",
"```\n",
"同じようなコードが並んでいる。`py4macro`のデータがアップデートされて`2020`年までのデータが含まれることになったとしよう。`for`ループを使うコードであれば`2019`を`2020`に一ヵ所だけ変更すれば良い(変更する必要もないコードを書くことも可能)。`for`ループを使わないコードで何ヵ所修正する必要があるか数えてみよう。面倒と感じないだろうか。それに修正箇所が増えればbugが紛れ込む可能性が増えていく。\n",
"````"
Expand Down
18 changes: 11 additions & 7 deletions 19_PPP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
"cell_type": "markdown",
"id": "7c0ddd8c",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
"heading_collapsed": true
},
"source": [
"## はじめに"
Expand Down Expand Up @@ -1047,6 +1046,7 @@
"id": "cc3f4f60",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true,
"tags": [
"remove-cell"
]
Expand All @@ -1071,7 +1071,8 @@
"id": "3784f324",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### はじめに"
Expand Down Expand Up @@ -1797,7 +1798,7 @@
"outputs": [],
"source": [
"ax = bigmac.plot('gdppc_yen', 'price_yen', kind='scatter', logx=True)\n",
"ax.set_xlabel('一人当たり実質GDP(円,対数)', fontsize=15)\n",
"ax.set_xlabel('一人当たり実質GDP(円,常用対数)', fontsize=15)\n",
"ax.set_ylabel('Big Mac価格(円)', fontsize=15)\n",
"pass"
]
Expand Down Expand Up @@ -1841,7 +1842,8 @@
"cell_type": "markdown",
"id": "ceba412e",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## 購買力平価と物価水準の分布"
Expand Down Expand Up @@ -2572,7 +2574,8 @@
"cell_type": "markdown",
"id": "aad8450d",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## 物価水準に対する所得の影響"
Expand Down Expand Up @@ -3358,7 +3361,8 @@
"cell_type": "markdown",
"id": "3f1a605d",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### PPPレートと市場為替レート:再考"
Expand Down

0 comments on commit df91cd3

Please sign in to comment.