Skip to content

Commit

Permalink
edit TS section; add Shumway to references
Browse files Browse the repository at this point in the history
  • Loading branch information
elizavetasemenova committed Nov 21, 2024
1 parent ab5223d commit 08d1acf
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 363 deletions.
2 changes: 1 addition & 1 deletion 06_Monte_Carlo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# The Monte Carlo method\n",
"\n",
"The Monte Carlo {cite}`metropolis1949monte, robert1999monte` method is a computational technique that uses <font color='orange'>random sampling</font> to estimate complex mathematical outcomes or solve problems that might be <font color='orange'>deterministic</font> in nature.\n",
"The Monte Carlo {cite}`metropolis1949monte, robert_monte_2004` method is a computational technique that uses <font color='orange'>random sampling</font> to estimate complex mathematical outcomes or solve problems that might be <font color='orange'>deterministic</font> in nature.\n",
"\n",
"The name “Monte Carlo” for the Monte Carlo methods has an origin that ties back to the famous Monte Carlo Casino located in Monaco. This name was not chosen because of any direct association with the mathematical principles behind these methods, but rather for its metaphorical connection to randomness and chance, which are central elements in both gambling and Monte Carlo simulations.\n",
"\n",
Expand Down
20 changes: 10 additions & 10 deletions 11_Bayesian_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -711,19 +711,19 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def plot_regression(x, y_mean, y_hpdi, height, ttl='Predictions with 89% CI)'):\n",
" # Sort values for plotting by x axis\n",
" # sort values for plotting by x axis\n",
" idx = jnp.argsort(x)\n",
" weight = x[idx]\n",
" mean = y_mean[idx]\n",
" hpdi = y_hpdi[:, idx]\n",
" ht = height[idx]\n",
"\n",
" # Plot\n",
" # plot\n",
" fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(6, 6))\n",
" ax.plot(weight, mean, color='teal')\n",
" ax.plot(weight, ht, 'o', color='orangered')\n",
Expand Down Expand Up @@ -764,7 +764,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -790,11 +790,11 @@
}
],
"source": [
"# Inference\n",
"# inference\n",
"rng_key = random.PRNGKey(0)\n",
"rng_key, rng_key_ = random.split(rng_key)\n",
"\n",
"# Run NUTS\n",
"# run NUTS\n",
"kernel = NUTS(model)\n",
"mcmc = MCMC(kernel, num_warmup=1000, num_samples=2000, num_chains=4, progress_bar=False)\n",
"mcmc.run(rng_key_, weight=weight, height=height)\n",
Expand All @@ -804,7 +804,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -832,7 +832,7 @@
}
],
"source": [
"# Check convergence\n",
"# check convergence\n",
"mcmc.print_summary()\n",
"data = az.from_numpyro(mcmc)\n",
"az.plot_trace(data, compact=True);"
Expand All @@ -845,7 +845,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -860,7 +860,7 @@
}
],
"source": [
"# Posterior predictive\n",
"# posterior predictive\n",
"rng_key, rng_key_ = random.split(rng_key)\n",
"predictive = Predictive(model, samples_1)\n",
"posterior_predictions = predictive(rng_key_, weight=weight)\n",
Expand Down
Loading

0 comments on commit 08d1acf

Please sign in to comment.