Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 071c292

Browse files
committed
fix(chapter_02): correctly perform a quadratic approximation
1 parent 37870e3 commit 071c292

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

notebooks/Chapter_02.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ begin
1616
using LaTeXStrings
1717
using StatisticalRethinking
1818
using StatisticalRethinkingPlots
19+
using MonteCarloMeasurements
1920
end
2021

2122
# ╔═╡ 6a78dd3a-9770-40d0-b344-e7678801499c
@@ -174,8 +175,9 @@ end
174175
# ╔═╡ e15efdfa-e64f-4f5b-a94c-6c5e135a9ec2
175176
let
176177
df = DataFrame(chain)
177-
μ = mean(df.p)
178-
σ = std(df.p)
178+
p = quap(df).coef.p
179+
μ = pmean(p)
180+
σ = pstd(p)
179181
b2 = Normal(μ, σ)
180182
plot!(x, pdf.(b2, x); style=:dash,
181183
label="Normal($(round(μ; digits=2)), $(round(σ; digits=2)))")
@@ -207,6 +209,7 @@ PLUTO_PROJECT_TOML_CONTENTS = """
207209
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
208210
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
209211
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
212+
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
210213
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
211214
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
212215
StatisticalRethinking = "2d09df54-9d0f-5258-8220-54c2a3d4fbee"
@@ -216,6 +219,7 @@ Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
216219
[compat]
217220
Distributions = "~0.25.107"
218221
LaTeXStrings = "~1.3.1"
222+
MonteCarloMeasurements = "~1.1.6"
219223
Optim = "~1.8.0"
220224
StatisticalRethinking = "~4.7.4"
221225
StatisticalRethinkingPlots = "~1.1.0"

0 commit comments

Comments
 (0)