Skip to content

Commit 71d3fb1

Browse files
committed
deploy: 0bfcac8
1 parent 46cf17c commit 71d3fb1

275 files changed

Lines changed: 10344 additions & 9687 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Binary file not shown.
30.4 KB
Loading

_notebooks/aiyagari.ipynb

Lines changed: 104 additions & 87 deletions
Large diffs are not rendered by default.

_notebooks/ak2.ipynb

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

_notebooks/ak_aiyagari.ipynb

Lines changed: 128 additions & 110 deletions
Large diffs are not rendered by default.

_notebooks/ar1_bayes.ipynb

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,33 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "18ced5a7",
5+
"id": "4480886e",
66
"metadata": {},
77
"source": [
88
"# Posterior Distributions for AR(1) Parameters"
99
]
1010
},
1111
{
1212
"cell_type": "markdown",
13-
"id": "3c79813b",
13+
"id": "4550bc58",
1414
"metadata": {},
1515
"source": [
1616
"# GPU\n",
1717
"\n",
18-
"This lecture was built using a machine with the latest CUDA and CUDANN frameworks installed with access to a GPU.\n",
18+
"This lecture was built using a machine with access to a GPU.\n",
1919
"\n",
20-
"To run this lecture on [Google Colab](https://colab.research.google.com/), click on the “play” icon top right, select Colab, and set the runtime environment to include a GPU.\n",
20+
"[Google Colab](https://colab.research.google.com/) has a free tier with GPUs\n",
21+
"that you can access as follows:\n",
2122
"\n",
22-
"To run this lecture on your own machine, you need to install the software listed following this notice."
23+
"1. Click on the “play” icon top right \n",
24+
"1. Select Colab \n",
25+
"1. Set the runtime environment to include a GPU "
2326
]
2427
},
2528
{
2629
"cell_type": "code",
2730
"execution_count": null,
28-
"id": "697c1e14",
31+
"id": "bc11defe",
2932
"metadata": {
3033
"hide-output": false
3134
},
@@ -36,7 +39,7 @@
3639
},
3740
{
3841
"cell_type": "markdown",
39-
"id": "510ed42f",
42+
"id": "4d1620ca",
4043
"metadata": {},
4144
"source": [
4245
"In addition to what’s included in base Anaconda, we need to install the following packages"
@@ -45,7 +48,7 @@
4548
{
4649
"cell_type": "code",
4750
"execution_count": null,
48-
"id": "0ba760f9",
51+
"id": "8387d646",
4952
"metadata": {
5053
"hide-output": false
5154
},
@@ -56,7 +59,7 @@
5659
},
5760
{
5861
"cell_type": "markdown",
59-
"id": "979aadb2",
62+
"id": "9492ed94",
6063
"metadata": {},
6164
"source": [
6265
"We’ll begin with some Python imports."
@@ -65,7 +68,7 @@
6568
{
6669
"cell_type": "code",
6770
"execution_count": null,
68-
"id": "747e3f8f",
71+
"id": "d989aa29",
6972
"metadata": {
7073
"hide-output": false
7174
},
@@ -89,7 +92,7 @@
8992
},
9093
{
9194
"cell_type": "markdown",
92-
"id": "b0d50bc4",
95+
"id": "806e7cad",
9396
"metadata": {},
9497
"source": [
9598
"This lecture uses Bayesian methods offered by [pymc](https://www.pymc.io/projects/docs/en/stable/) and [numpyro](https://num.pyro.ai/en/stable/) to make statistical inferences about two parameters of a univariate first-order autoregression.\n",
@@ -185,7 +188,7 @@
185188
{
186189
"cell_type": "code",
187190
"execution_count": null,
188-
"id": "f863c76f",
191+
"id": "d4d988b3",
189192
"metadata": {
190193
"hide-output": false
191194
},
@@ -215,7 +218,7 @@
215218
{
216219
"cell_type": "code",
217220
"execution_count": null,
218-
"id": "88e84ff6",
221+
"id": "270e075d",
219222
"metadata": {
220223
"hide-output": false
221224
},
@@ -227,7 +230,7 @@
227230
},
228231
{
229232
"cell_type": "markdown",
230-
"id": "3cc71268",
233+
"id": "0eb5e83e",
231234
"metadata": {},
232235
"source": [
233236
"Now we shall use Bayes’ law to construct a posterior distribution, conditioning on the initial value of $ y_0 $.\n",
@@ -239,7 +242,7 @@
239242
},
240243
{
241244
"cell_type": "markdown",
242-
"id": "c51a7933",
245+
"id": "599ab857",
243246
"metadata": {},
244247
"source": [
245248
"## PyMC Implementation\n",
@@ -251,7 +254,7 @@
251254
{
252255
"cell_type": "code",
253256
"execution_count": null,
254-
"id": "cfd857b6",
257+
"id": "2de368d6",
255258
"metadata": {
256259
"hide-output": false
257260
},
@@ -274,7 +277,7 @@
274277
},
275278
{
276279
"cell_type": "markdown",
277-
"id": "8fbecca2",
280+
"id": "330d418a",
278281
"metadata": {},
279282
"source": [
280283
"[pmc.sample](https://www.pymc.io/projects/docs/en/v5.10.0/api/generated/pymc.sample.html#pymc-sample) by default uses the NUTS samplers to generate samples as shown in the below cell:"
@@ -283,7 +286,7 @@
283286
{
284287
"cell_type": "code",
285288
"execution_count": null,
286-
"id": "f474ffc2",
289+
"id": "3c53fefc",
287290
"metadata": {
288291
"hide-output": false
289292
},
@@ -296,7 +299,7 @@
296299
{
297300
"cell_type": "code",
298301
"execution_count": null,
299-
"id": "c29dc97d",
302+
"id": "5037b8bf",
300303
"metadata": {
301304
"hide-output": false
302305
},
@@ -308,7 +311,7 @@
308311
},
309312
{
310313
"cell_type": "markdown",
311-
"id": "7853e601",
314+
"id": "67b66300",
312315
"metadata": {},
313316
"source": [
314317
"Evidently, the posteriors aren’t centered on the true values of $ .5, 1 $ that we used to generate the data.\n",
@@ -323,7 +326,7 @@
323326
{
324327
"cell_type": "code",
325328
"execution_count": null,
326-
"id": "1fe6b4fc",
329+
"id": "66f6f117",
327330
"metadata": {
328331
"hide-output": false
329332
},
@@ -337,7 +340,7 @@
337340
},
338341
{
339342
"cell_type": "markdown",
340-
"id": "890ff987",
343+
"id": "f42ea1fd",
341344
"metadata": {},
342345
"source": [
343346
"Now we shall compute a posterior distribution after seeing the same data but instead assuming that $ y_0 $ is drawn from the stationary distribution.\n",
@@ -354,7 +357,7 @@
354357
{
355358
"cell_type": "code",
356359
"execution_count": null,
357-
"id": "a789393a",
360+
"id": "3251a3cd",
358361
"metadata": {
359362
"hide-output": false
360363
},
@@ -380,7 +383,7 @@
380383
{
381384
"cell_type": "code",
382385
"execution_count": null,
383-
"id": "f6a4866b",
386+
"id": "51a0687e",
384387
"metadata": {
385388
"hide-output": false
386389
},
@@ -395,7 +398,7 @@
395398
{
396399
"cell_type": "code",
397400
"execution_count": null,
398-
"id": "8b333c4f",
401+
"id": "f7aec957",
399402
"metadata": {
400403
"hide-output": false
401404
},
@@ -408,7 +411,7 @@
408411
{
409412
"cell_type": "code",
410413
"execution_count": null,
411-
"id": "55720f12",
414+
"id": "e1fd2d60",
412415
"metadata": {
413416
"hide-output": false
414417
},
@@ -422,7 +425,7 @@
422425
},
423426
{
424427
"cell_type": "markdown",
425-
"id": "1fcc5325",
428+
"id": "70752930",
426429
"metadata": {},
427430
"source": [
428431
"Please note how the posterior for $ \\rho $ has shifted to the right relative to when we conditioned on $ y_0 $ instead of assuming that $ y_0 $ is drawn from the stationary distribution.\n",
@@ -439,7 +442,7 @@
439442
},
440443
{
441444
"cell_type": "markdown",
442-
"id": "d09281f4",
445+
"id": "bab7fe1b",
443446
"metadata": {},
444447
"source": [
445448
"## Numpyro Implementation"
@@ -448,7 +451,7 @@
448451
{
449452
"cell_type": "code",
450453
"execution_count": null,
451-
"id": "17e665d1",
454+
"id": "31bbfec8",
452455
"metadata": {
453456
"hide-output": false
454457
},
@@ -484,7 +487,7 @@
484487
{
485488
"cell_type": "code",
486489
"execution_count": null,
487-
"id": "bd045277",
490+
"id": "813ca322",
488491
"metadata": {
489492
"hide-output": false
490493
},
@@ -505,7 +508,7 @@
505508
{
506509
"cell_type": "code",
507510
"execution_count": null,
508-
"id": "4b4336f6",
511+
"id": "58463276",
509512
"metadata": {
510513
"hide-output": false
511514
},
@@ -525,7 +528,7 @@
525528
{
526529
"cell_type": "code",
527530
"execution_count": null,
528-
"id": "a8df7780",
531+
"id": "f0fc347e",
529532
"metadata": {
530533
"hide-output": false
531534
},
@@ -537,7 +540,7 @@
537540
{
538541
"cell_type": "code",
539542
"execution_count": null,
540-
"id": "6eccfecd",
543+
"id": "b8e9e35a",
541544
"metadata": {
542545
"hide-output": false
543546
},
@@ -548,7 +551,7 @@
548551
},
549552
{
550553
"cell_type": "markdown",
551-
"id": "85fd70d5",
554+
"id": "b3d5a9f3",
552555
"metadata": {},
553556
"source": [
554557
"Next, we again compute the posterior under the assumption that $ y_0 $ is drawn from the stationary distribution, so that\n",
@@ -563,7 +566,7 @@
563566
{
564567
"cell_type": "code",
565568
"execution_count": null,
566-
"id": "99221a9d",
569+
"id": "58dac77b",
567570
"metadata": {
568571
"hide-output": false
569572
},
@@ -588,7 +591,7 @@
588591
{
589592
"cell_type": "code",
590593
"execution_count": null,
591-
"id": "4e718266",
594+
"id": "08c6f462",
592595
"metadata": {
593596
"hide-output": false
594597
},
@@ -608,7 +611,7 @@
608611
{
609612
"cell_type": "code",
610613
"execution_count": null,
611-
"id": "7d5cb384",
614+
"id": "8897e861",
612615
"metadata": {
613616
"hide-output": false
614617
},
@@ -620,7 +623,7 @@
620623
{
621624
"cell_type": "code",
622625
"execution_count": null,
623-
"id": "9532bfb1",
626+
"id": "97a6b1bb",
624627
"metadata": {
625628
"hide-output": false
626629
},
@@ -631,7 +634,7 @@
631634
},
632635
{
633636
"cell_type": "markdown",
634-
"id": "4bff71c8",
637+
"id": "8c7ba5ad",
635638
"metadata": {},
636639
"source": [
637640
"Look what happened to the posterior!\n",
@@ -646,7 +649,7 @@
646649
}
647650
],
648651
"metadata": {
649-
"date": 1764378007.2089982,
652+
"date": 1764547274.0689824,
650653
"filename": "ar1_bayes.md",
651654
"kernelspec": {
652655
"display_name": "Python",

0 commit comments

Comments
 (0)