Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Jul 6, 2024
1 parent 27c228b commit 07ad4a0
Show file tree
Hide file tree
Showing 67 changed files with 34,353 additions and 14,459 deletions.
1,698 changes: 1,698 additions & 0 deletions content/.jupyter_cache/executed/d9f6130d6ab67bfc7f79f4ff62f532f3/base.ipynb

Large diffs are not rendered by default.

Binary file modified content/.jupyter_cache/global.db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": "6033e7a81658aa4d7aed6e8c08d64e85",
"hash": "ee1e3ab46601401d12010460f9a3436a",
"result": {
"engine": "jupyter",
"markdown": "# Fundamentals of Bayesian Modeling in Julia\n\n![](https://img.shields.io/badge/status-not_started-red)\n\n\n## Very quick intro to Julia and Turing\n\nGoal is to teach just enough so that the reader understands the code.\n\n### Generate Data from Normal Distribution\n\n::: {#6eaf817c .cell execution_count=1}\n``` {.julia .cell-code}\nusing Turing, Distributions, Random\nusing Makie\n\n# μ=100, σ=15\niq = rand(Normal(100, 15), 500)\n```\n\n::: {.cell-output .cell-output-display execution_count=2}\n```\n500-element Vector{Float64}:\n 98.48776743748695\n 86.32452491238901\n 78.83526938610933\n 113.04410457290572\n 97.40745839499718\n 97.97419028900438\n 88.40275967411239\n 92.72164237452724\n 113.32790576148362\n 78.51901725613449\n 89.44848393975448\n 110.37730425103749\n 90.66395248256771\n ⋮\n 112.27965213239929\n 110.4084690224403\n 117.07901096715132\n 104.56556661142926\n 115.76409270035695\n 102.61126569224227\n 92.7517736224979\n 111.46970868742785\n 93.68344400954143\n 109.85853656837163\n 98.05396623359759\n 121.90982884976155\n```\n:::\n:::\n\n\n::: {#5ebbc89c .cell execution_count=2}\n``` {.julia .cell-code}\nfig = Figure()\nax = Axis(fig[1, 1], title=\"Distribution\")\ndensity!(ax, iq)\nfig\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.\n└ @ Makie C:\\Users\\domma\\.julia\\packages\\Makie\\VRavR\\src\\scenes.jl:220\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=3}\n![](1_introduction_files/figure-html/cell-3-output-2.svg){}\n:::\n:::\n\n\n### Recover Distribution Parameters with Turing\n\n::: {#c3c318fd .cell execution_count=3}\n``` {.julia .cell-code}\n@model function model_gaussian(x)\n # Priors\n μ ~ Uniform(0, 200)\n σ ~ Uniform(0, 30)\n\n # Check against data\n for i in 1:length(x)\n x[i] ~ Normal(μ, σ)\n end\nend\n\nmodel = model_gaussian(iq)\nsampling_results = sample(model, NUTS(), 400)\n\n# Summary (95% CI)\nsummarystats(sampling_results)\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n┌ Info: Found initial step size\n└ ϵ = 0.025\n\rSampling: 0%|█ | ETA: 0:00:32\rSampling: 100%|█████████████████████████████████████████| Time: 0:00:01\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=4}\n\n::: {.ansi-escaped-output}\n```{=html}\n<pre>Summary Statistics\n <span class=\"ansi-bold\"> parameters </span> <span class=\"ansi-bold\"> mean </span> <span class=\"ansi-bold\"> std </span> <span class=\"ansi-bold\"> mcse </span> <span class=\"ansi-bold\"> ess_bulk </span> <span class=\"ansi-bold\"> ess_tail </span> <span class=\"ansi-bold\"> rhat </span> <span class=\"ansi-bold\"> e</span> ⋯\n <span class=\"ansi-bright-black-fg\"> Symbol </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> </span> ⋯\n μ 99.7656 0.6604 0.0334 396.7968 287.6290 1.0019 ⋯\n σ 15.8141 0.5585 0.0280 390.8097 254.6258 1.0045 ⋯\n<span class=\"ansi-cyan-fg\"> 1 column omitted</span>\n</pre>\n```\n:::\n\n:::\n:::\n\n\n## Linear Models\n\nUnderstand what the parameters mean (intercept, slopes, sigma).\n\n3. Boostrapping: Introduce concepts related to pseudo-posterior distribution description\n4. Hierarchical Models: Simpson's paradox, random effects, how to leverage them to model interindividual differences\n5. Bayesian estimation: introduce Bayesian estimation and priors over parameters\n6. Bayesian mixed linear regression: put everything together\n\n",
"markdown": "# Fundamentals of Bayesian Modeling in Julia\n\n![](https://img.shields.io/badge/status-not_started-red)\n\n\n## Very quick intro to Julia and Turing\n\nGoal is to teach just enough so that the reader understands the code.\n\n### Generate Data from Normal Distribution\n\n::: {#86de7312 .cell execution_count=1}\n``` {.julia .cell-code}\nusing Turing, Distributions, Random\nusing Makie\n\n# Random sample from a Normal(μ=100, σ=15)\niq = rand(Normal(100, 15), 500)\n```\n:::\n\n\n::: {#8df07ece .cell execution_count=2}\n``` {.julia .cell-code}\nfig = Figure()\nax = Axis(fig[1, 1], title=\"Distribution\")\ndensity!(ax, iq)\nfig\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n┌ Warning: Found `resolution` in the theme when creating a `Scene`. The `resolution` keyword for `Scene`s and `Figure`s has been deprecated. Use `Figure(; size = ...` or `Scene(; size = ...)` instead, which better reflects that this is a unitless size and not a pixel resolution. The key could also come from `set_theme!` calls or related theming functions.\n└ @ Makie C:\\Users\\domma\\.julia\\packages\\Makie\\VRavR\\src\\scenes.jl:220\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=3}\n![](1_introduction_files/figure-html/cell-3-output-2.svg){}\n:::\n:::\n\n\n### Recover Distribution Parameters with Turing\n\n::: {#3276026a .cell execution_count=3}\n``` {.julia .cell-code}\n@model function model_gaussian(x)\n # Priors\n μ ~ Uniform(0, 200)\n σ ~ Uniform(0, 30)\n\n # Check against each datapoint\n for i in 1:length(x)\n x[i] ~ Normal(μ, σ)\n end\nend\n\nmodel = model_gaussian(iq)\nsampling_results = sample(model, NUTS(), 400)\n\n# Summary (95% CI)\nsummarystats(sampling_results)\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n┌ Info: Found initial step size\n└ ϵ = 0.05\n\rSampling: 0%|█ | ETA: 0:00:29\rSampling: 100%|█████████████████████████████████████████| Time: 0:00:00\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=4}\n\n::: {.ansi-escaped-output}\n```{=html}\n<pre>Summary Statistics\n <span class=\"ansi-bold\"> parameters </span> <span class=\"ansi-bold\"> mean </span> <span class=\"ansi-bold\"> std </span> <span class=\"ansi-bold\"> mcse </span> <span class=\"ansi-bold\"> ess_bulk </span> <span class=\"ansi-bold\"> ess_tail </span> <span class=\"ansi-bold\"> rhat </span> <span class=\"ansi-bold\"> e</span> ⋯\n <span class=\"ansi-bright-black-fg\"> Symbol </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> Float64 </span> <span class=\"ansi-bright-black-fg\"> </span> ⋯\n μ 99.7082 0.6935 0.0367 349.6040 232.8456 1.0045 ⋯\n σ 15.2626 0.4713 0.0255 337.7052 265.8666 1.0002 ⋯\n<span class=\"ansi-cyan-fg\"> 1 column omitted</span>\n</pre>\n```\n:::\n\n:::\n:::\n\n\n## Linear Models\n\nUnderstand what the parameters mean (intercept, slopes, sigma).\n\n## Boostrapping\n\nIntroduce concepts related to pseudo-posterior distribution description\n\n## Hierarchical Models\n\nSimpson's paradox, random effects, how to leverage them to model interindividual differences\n\n## Bayesian estimation\n\nintroduce Bayesian estimation and priors over parameters\n\n## Bayesian mixed linear regression\n\nput everything together\n\n",
"supporting": [
"1_introduction_files\\figure-html"
],
Expand Down
Loading

0 comments on commit 07ad4a0

Please sign in to comment.