Skip to content

Commit

Permalink
deploy: bc6c2cd
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcky committed Jan 29, 2024
1 parent 3850bc7 commit 9e4779f
Show file tree
Hide file tree
Showing 270 changed files with 4,070 additions and 5,290 deletions.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
70 changes: 35 additions & 35 deletions _notebooks/ar1_bayes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "6101b12d",
"id": "e3c19ac4",
"metadata": {},
"source": [
"# Posterior Distributions for AR(1) Parameters\n",
Expand All @@ -13,7 +13,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "088fb117",
"id": "194738d6",
"metadata": {
"hide-output": false
},
Expand All @@ -25,7 +25,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cbeb1a42",
"id": "a810f395",
"metadata": {
"hide-output": false
},
Expand All @@ -49,7 +49,7 @@
},
{
"cell_type": "markdown",
"id": "7f68f108",
"id": "8903c2ed",
"metadata": {},
"source": [
"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",
Expand Down Expand Up @@ -145,7 +145,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4d968167",
"id": "6080c7e5",
"metadata": {
"hide-output": false
},
Expand Down Expand Up @@ -175,7 +175,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2ff374b4",
"id": "2ec5bab0",
"metadata": {
"hide-output": false
},
Expand All @@ -187,7 +187,7 @@
},
{
"cell_type": "markdown",
"id": "6594b515",
"id": "0329be6f",
"metadata": {},
"source": [
"Now we shall use Bayes’ law to construct a posterior distribution, conditioning on the initial value of $ y_0 $.\n",
Expand All @@ -199,7 +199,7 @@
},
{
"cell_type": "markdown",
"id": "00b542c4",
"id": "287851ae",
"metadata": {},
"source": [
"## PyMC Implementation\n",
Expand All @@ -211,7 +211,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "22bc8a05",
"id": "e3ebfdd8",
"metadata": {
"hide-output": false
},
Expand All @@ -234,7 +234,7 @@
},
{
"cell_type": "markdown",
"id": "b0f47a54",
"id": "90996156",
"metadata": {},
"source": [
"[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:"
Expand All @@ -243,7 +243,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5750f3a9",
"id": "356d6214",
"metadata": {
"hide-output": false
},
Expand All @@ -256,7 +256,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8f00983c",
"id": "770f0cde",
"metadata": {
"hide-output": false
},
Expand All @@ -268,22 +268,22 @@
},
{
"cell_type": "markdown",
"id": "c85dd51b",
"id": "658500ab",
"metadata": {},
"source": [
"Evidently, the posteriors aren’t centered on the true values of $ .5, 1 $ that we used to generate the data.\n",
"\n",
"This is a symptom of the classic **Hurwicz bias** for first order autoregressive processes (see Leonid Hurwicz [[Hur50](https://python.quantecon.org/zreferences.html#id244)].)\n",
"This is a symptom of the classic **Hurwicz bias** for first order autoregressive processes (see Leonid Hurwicz [[Hur50](https://python.quantecon.org/zreferences.html#id246)].)\n",
"\n",
"The Hurwicz bias is worse the smaller is the sample (see [[OW69](https://python.quantecon.org/zreferences.html#id243)]).\n",
"The Hurwicz bias is worse the smaller is the sample (see [[OW69](https://python.quantecon.org/zreferences.html#id245)]).\n",
"\n",
"Be that as it may, here is more information about the posterior."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ecc856c2",
"id": "a2f4febf",
"metadata": {
"hide-output": false
},
Expand All @@ -297,7 +297,7 @@
},
{
"cell_type": "markdown",
"id": "31e05ee2",
"id": "f7465ac3",
"metadata": {},
"source": [
"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",
Expand All @@ -314,7 +314,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eaef1c61",
"id": "b629c3d3",
"metadata": {
"hide-output": false
},
Expand All @@ -340,7 +340,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "80cd1aa8",
"id": "8be43f79",
"metadata": {
"hide-output": false
},
Expand All @@ -355,7 +355,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "34b8b76f",
"id": "1139dd10",
"metadata": {
"hide-output": false
},
Expand All @@ -368,7 +368,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f1baae3c",
"id": "b696cc4e",
"metadata": {
"hide-output": false
},
Expand All @@ -382,7 +382,7 @@
},
{
"cell_type": "markdown",
"id": "00f3dd34",
"id": "c4b2d8df",
"metadata": {},
"source": [
"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",
Expand All @@ -399,7 +399,7 @@
},
{
"cell_type": "markdown",
"id": "133d1d92",
"id": "728ea887",
"metadata": {},
"source": [
"## Numpyro Implementation"
Expand All @@ -408,7 +408,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "49a4da18",
"id": "15ad0d76",
"metadata": {
"hide-output": false
},
Expand Down Expand Up @@ -444,7 +444,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fb696090",
"id": "5c2dc83b",
"metadata": {
"hide-output": false
},
Expand All @@ -465,7 +465,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d68e8c33",
"id": "d04c5e88",
"metadata": {
"hide-output": false
},
Expand All @@ -485,7 +485,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "70aff6ac",
"id": "9d6d5ac3",
"metadata": {
"hide-output": false
},
Expand All @@ -497,7 +497,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "addfc73b",
"id": "b365d10f",
"metadata": {
"hide-output": false
},
Expand All @@ -508,7 +508,7 @@
},
{
"cell_type": "markdown",
"id": "b4d12b8e",
"id": "1f29a3d6",
"metadata": {},
"source": [
"Next, we again compute the posterior under the assumption that $ y_0 $ is drawn from the stationary distribution, so that\n",
Expand All @@ -523,7 +523,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c0dfc979",
"id": "236f75ac",
"metadata": {
"hide-output": false
},
Expand All @@ -548,7 +548,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "69a309ec",
"id": "434a6c10",
"metadata": {
"hide-output": false
},
Expand All @@ -568,7 +568,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "236344e9",
"id": "04f5d399",
"metadata": {
"hide-output": false
},
Expand All @@ -580,7 +580,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "576d58cf",
"id": "5b948fb9",
"metadata": {
"hide-output": false
},
Expand All @@ -591,7 +591,7 @@
},
{
"cell_type": "markdown",
"id": "6248f9d1",
"id": "072e44cf",
"metadata": {},
"source": [
"Look what happened to the posterior!\n",
Expand All @@ -606,7 +606,7 @@
}
],
"metadata": {
"date": 1706246574.4990308,
"date": 1706493928.679338,
"filename": "ar1_bayes.md",
"kernelspec": {
"display_name": "Python",
Expand Down
Loading

0 comments on commit 9e4779f

Please sign in to comment.