diff --git a/lectures/Bayesian Machine Learning.jl b/lectures/Bayesian Machine Learning.jl index 97af7f9e..b40dd6a8 100644 --- a/lectures/Bayesian Machine Learning.jl +++ b/lectures/Bayesian Machine Learning.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/scientific-inquiry-loop-w-BML-eqs.png?raw=true" @@ -31,13 +31,10 @@ using Distributions, StatsPlots, SpecialFunctions using Plots, LaTeXStrings, Plots.PlotMeasures # ╔═╡ caba8eee-dfea-45bc-a8a7-1dd20a1fa994 -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 6a23b828-d294-11ef-371a-05d061144a43 -md""" -# Bayesian Machine Learning - -""" +title("Bayesian Machine Learning") # ╔═╡ 6be2e966-4048-44d0-a37e-95060e3fe30b PlutoUI.TableOfContents() @@ -67,7 +64,7 @@ md""" # ╔═╡ 6a24376c-d294-11ef-348a-e9027bd0ec29 md""" -$(section_outline("Challenge:", "Predicting a Coin Toss")) +$(challenge_statement("Predicting a Coin Toss")) ##### Problem @@ -258,7 +255,7 @@ Then, solve the desired inference problem for the posterior over the model ``m_k """ # ╔═╡ 74fa1925-0d9f-47f6-a6bd-b822948a4fbc -details("Proof this yourself, and click for solution", +details("Prove this yourself, and click for solution", md""" ```math \begin{align} @@ -348,7 +345,7 @@ As an aside, in the (statistics and machine learning) literature, performance co """ # ╔═╡ 99db44c9-185c-4f39-ae5e-1a4cd751d980 -details("Proof this yourself, and click for solution", +details("Prove this yourself, and click for solution", md""" ```math \begin{align*} @@ -400,7 +397,7 @@ p(x|D) = \int \underbrace{p(x|\theta)}_{\substack{\text{data } \\ \text{generati """ # ╔═╡ f6ee5570-9b92-42b6-baf3-3eed5352a060 -details("Proof this yourself, and click for solution", +details("Prove this yourself, and click for solution", md""" ```math \begin{align*} @@ -518,7 +515,7 @@ md""" """ # ╔═╡ 6a9ad1c4-dfb2-4987-9ddc-da6131605083 -details("Click for proof", +hide_proof( md""" ```math \begin{flalign} @@ -739,7 +736,7 @@ where ``B(\alpha,\beta) \triangleq \frac{\Gamma(\alpha) \Gamma(\beta)}{\Gamma(\a """ # ╔═╡ b426df32-5629-4773-b862-101cfbd82d42 -details("Proof this, and click for solution", +details("Prove this, and click for solution", md""" ```math \begin{flalign*} @@ -873,7 +870,7 @@ md""" """ # ╔═╡ 90f691ad-046c-4595-99b0-19a1d6cb599e -details("Proof this yourself, and click for solution", +details("Prove this yourself, and click for solution", md""" ```math \begin{align*} @@ -902,7 +899,7 @@ For large ``N``, the gain goes to ``1`` and ``\left. p(x_\bullet=1|D)\right|_{N\ """ # ╔═╡ 6a2abb16-d294-11ef-0243-d376e8a39bb0 -section_outline("Code Example:", "Bayesian Evolution for the Coin Toss") +code_example("Bayesian Evolution for the Coin Toss") # ╔═╡ 6a2acb7e-d294-11ef-185c-9d49ce79c31b md""" @@ -1249,7 +1246,7 @@ $(section_outline("Excercises","",header_level=1)) \,\mathrm{d}{\theta} ``` -Proof that the Bayes estimate minimizes the mean-squared error, i.e., proof that +Prove that the Bayes estimate minimizes the mean-squared error, i.e., Prove that ```math \hat \theta_{bayes} = \arg\min_{\hat \theta} \int_\theta (\hat \theta -\theta)^2 p \left( \theta |D \right) \,\mathrm{d}{\theta} @@ -1257,7 +1254,7 @@ Proof that the Bayes estimate minimizes the mean-squared error, i.e., proof that """ # ╔═╡ 7dd9a456-9dca-47c8-98c5-51f87f28e6a4 -details("Click for solution", +hide_solution( md""" To minimize the expected mean-squared error we will look for ``\hat{\theta}`` that makes the gradient of the integral with respect to ``\hat{\theta}`` vanish. @@ -1296,7 +1293,7 @@ and a given data set ``D=\{x_1, x_2,\ldots,x_N\}``. """ # ╔═╡ 664d4183-edb6-4818-a44b-bf4c0a22a33c -details("Click for solution", +hide_solution( md""" - (a) The likelihood is given by ``p(D|\mu) = \mu^n\cdot (1-\mu)^{(N-n)}``. It follows that @@ -1387,7 +1384,7 @@ Now assume that the model priors are given by """ # ╔═╡ de08c2a1-c5e3-4add-8b22-2c633247da48 -details("Click for solutions", +hide_solution( md""" - (a) Work out the probability ``p(x=1|m_1)``. @@ -1581,20 +1578,18 @@ wideq(x) = PlutoUI.ExperimentalLayout.Div([x]; style="min-width: max-content;") # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.119" LaTeXStrings = "~1.4.0" Plots = "~1.40.13" -PlutoTeachingTools = "~0.4.5" -PlutoUI = "~0.7.69" SpecialFunctions = "~2.5.1" StatsPlots = "~0.15.7" """ @@ -1603,9 +1598,9 @@ StatsPlots = "~0.15.7" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "abd58c9f6700767f652d81b5f75ddf0c01e33a11" +project_hash = "c32aa4de72bf9cb3845a24e6c53ef8abfcfaabe9" [[deps.AbstractFFTs]] deps = ["LinearAlgebra"] @@ -1676,6 +1671,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -2317,7 +2318,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2426,9 +2427,9 @@ version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] diff --git a/lectures/Course Syllabus.jl b/lectures/Course Syllabus.jl index 808cda24..23688ab0 100644 --- a/lectures/Course Syllabus.jl +++ b/lectures/Course Syllabus.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.8 +# v0.20.15 #> [frontmatter] #> description = "Course Syllabus" @@ -12,13 +12,10 @@ using Markdown using InteractiveUtils # ╔═╡ f96d047f-9efa-4889-8b4e-a8d96677d072 -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 0cfd4bc0-d294-11ef-3537-630954a9dd27 -md""" -# 5SSD0 Course Syllabus - -""" +title("5SSD0 Course Syllabus") # ╔═╡ 467c8189-b5d3-4eaf-8886-6ae53136dd8f PlutoUI.TableOfContents() @@ -189,21 +186,19 @@ md""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" [compat] -PlutoTeachingTools = "~0.3.1" -PlutoUI = "~0.7.62" +BmlipTeachingTools = "~1.1.0" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.9" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "693d399a999d5d7e020fb11475f075391b5e2525" +project_hash = "e635641d8e55b0485ecb2515c1996f4b47f0454e" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -213,25 +208,33 @@ version = "1.3.2" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +version = "1.1.2" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "062c5e1a5bf6ada13db96a4ae4749a4c2234f521" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "1.3.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" [[deps.ColorTypes]] deps = ["FixedPointNumbers", "Random"] -git-tree-sha1 = "b10d0b65641d57b8b4d5e234446582de5047050d" +git-tree-sha1 = "67e11ee83a43eb71ddc950302c53bf33f0690dfe" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -version = "0.11.5" +version = "0.12.1" + + [deps.ColorTypes.extensions] + StyledStringsExt = "StyledStrings" + + [deps.ColorTypes.weakdeps] + StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -241,6 +244,7 @@ version = "1.1.1+0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" [[deps.Downloads]] deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] @@ -249,6 +253,7 @@ version = "1.6.0" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" [[deps.FixedPointNumbers]] deps = ["Statistics"] @@ -282,6 +287,7 @@ version = "0.2.5" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -289,12 +295,6 @@ git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.4" -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "6ac9e4acc417a5b534ace12690bc6973c25b862f" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.3" - [[deps.LaTeXStrings]] git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c" uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" @@ -302,19 +302,21 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "cd10d2cc78d34c0e2a3a36420ab607b611debfbb" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.7" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" SparseArraysExt = "SparseArrays" SymEngineExt = "SymEngine" + TectonicExt = "tectonic_jll" [deps.Latexify.weakdeps] DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SymEngine = "123dc426-2d89-5057-bbad-38513e3affd8" + tectonic_jll = "d7dd28d6-a5e6-559c-9131-7eb760cdacc5" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] @@ -324,16 +326,17 @@ version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "8.6.0+0" [[deps.LibGit2]] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" [[deps.LibGit2_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.2+0" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] @@ -342,19 +345,16 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[deps.LoweredCodeUtils]] -deps = ["JuliaInterpreter"] -git-tree-sha1 = "4ef1c538614e3ec30cb6383b9eb0326a5c3a9763" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.3.0" +version = "1.11.0" [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" @@ -369,18 +369,20 @@ version = "0.5.16" [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.6+0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2023.12.12" [[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" @@ -389,12 +391,12 @@ version = "1.2.0" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.27+1" [[deps.OrderedCollections]] -git-tree-sha1 = "cc4054e898b852042d7b503313f7ad03de99c3dd" +git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.8.0" +version = "1.8.1" [[deps.Parsers]] deps = ["Dates", "PrecompileTools", "UUIDs"] @@ -403,33 +405,27 @@ uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" version = "2.8.3" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.11.0" -[[deps.PlutoHooks]] -deps = ["InteractiveUtils", "Markdown", "UUIDs"] -git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" -version = "0.0.5" + [deps.Pkg.extensions] + REPLExt = "REPL" -[[deps.PlutoLinks]] -deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] -git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" -version = "0.1.6" + [deps.Pkg.weakdeps] + REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.PlutoTeachingTools]] -deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoLinks", "PlutoUI"] -git-tree-sha1 = "8252b5de1f81dc103eb0293523ddf917695adea1" +deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.3.1" +version = "0.4.5" [[deps.PlutoUI]] -deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "d3de2694b52a01ce61a036f18ea9c0f61c4a9230" +deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.62" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -439,21 +435,19 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" [[deps.Reexport]] git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" @@ -466,42 +460,25 @@ git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.3.1" -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"] -git-tree-sha1 = "cedc9f9013f7beabd8a9c6d2e22c0ca7c5c2a8ed" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.7.6" - - [deps.Revise.extensions] - DistributedExt = "Distributed" - - [deps.Revise.weakdeps] - Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" - [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[deps.Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[deps.SparseArrays]] -deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" +version = "1.11.0" [[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.11.1" -[[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] -uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] + + [deps.Statistics.weakdeps] + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.TOML]] deps = ["Dates"] @@ -516,23 +493,26 @@ version = "1.10.0" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" [[deps.Tricks]] -git-tree-sha1 = "6cae795a5a9313bbb4f60683f7263318fc7d1505" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.10" +version = "0.1.12" [[deps.URIs]] -git-tree-sha1 = "cbbebadbcc76c5ca1cc4b4f3b0614b3e603b5000" +git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.5.2" +version = "1.6.1" [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" [[deps.Zlib_jll]] deps = ["Libdl"] @@ -547,7 +527,7 @@ version = "5.11.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.59.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/lectures/Discriminative Classification.jl b/lectures/Discriminative Classification.jl index 019cea7e..f1837379 100644 --- a/lectures/Discriminative Classification.jl +++ b/lectures/Discriminative Classification.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/Figure4.9.png?raw=true" @@ -37,11 +37,10 @@ using MarkdownLiteral: @mdx using Distributions # ╔═╡ e379cc2a-43f8-432f-84fc-a88fd4f3ad0a -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 25eefb10-d294-11ef-0734-2daf18636e8e -md""" -# Discriminative Classification +title("Discriminative Classification") """ @@ -70,7 +69,7 @@ md""" """ # ╔═╡ fe66a986-2f55-4417-a71d-b3b99f6369cc -section_outline("Challenge:", "difficult class-conditional data distributions" , color= "red" ) +challenge_statement("difficult class-conditional data distributions" , color= "red" ) # ╔═╡ 25ef2806-d294-11ef-3cb6-0f3e76b9177e md""" @@ -421,7 +420,7 @@ The gradient ``\nabla_{w_k} \mathrm{L}(w)`` to the weight ``w_k`` can be worked """ # ╔═╡ 3b24b142-2239-4951-9177-ff87b5da4b68 -details("Click for proof", +hide_proof( md""" The Log-likelihood is @@ -466,7 +465,7 @@ until convergence. """ # ╔═╡ 7932fff4-0568-49de-b34c-711e51487ae3 -section_outline("Challenge Revisited:", "Bayesian Logistic Regression for Difficult Class-conditional Data Distributions" , color= "green" ) +challenge_solution("Bayesian Logistic Regression for Difficult Class-conditional Data Distributions" , color= "green" ) # ╔═╡ 25f3bef2-d294-11ef-1438-e9f7e469336f md""" @@ -599,7 +598,7 @@ is a straight line. """ # ╔═╡ 9554ed0b-69dd-443c-9538-03a4117eeb78 -details("Click for solution", +hide_proof( md""" ```math @@ -755,32 +754,30 @@ end # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" MarkdownLiteral = "736d6165-7244-6769-4267-6b50796e6954" Optim = "429524aa-4258-5aef-a3af-852621145aeb" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.120" LaTeXStrings = "~1.4.0" MarkdownLiteral = "~0.1.2" Optim = "~1.13.2" Plots = "~1.40.17" -PlutoTeachingTools = "~0.4.4" -PlutoUI = "~0.7.69" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "3af9d070de921b89310e964c2b511252864a26e8" +project_hash = "4c1f4566735b2d723283baf2680f47646d64d470" [[deps.ADTypes]] git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" @@ -872,6 +869,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1017,9 +1020,9 @@ version = "1.15.1" [[deps.DifferentiationInterface]] deps = ["ADTypes", "LinearAlgebra"] -git-tree-sha1 = "53970db0989d231937cd96c0b0ace67f38da274e" +git-tree-sha1 = "38989b1532a3c6e2341d52b77c5475c42c3318a8" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.5" +version = "0.7.6" [deps.DifferentiationInterface.extensions] DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" @@ -1552,7 +1555,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] diff --git a/lectures/Dynamic Models.jl b/lectures/Dynamic Models.jl index cc4ea8e0..39f5d67c 100644 --- a/lectures/Dynamic Models.jl +++ b/lectures/Dynamic Models.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/Faragher-2012-cart-1.png?raw=true" @@ -31,13 +31,10 @@ using RxInfer, LinearAlgebra using Plots, Distributions, Images, LaTeXStrings # ╔═╡ e66b2193-87c8-4645-bfcc-643ee006383a -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 27289f68-d294-11ef-37d6-e399ed72a1d0 -md""" -# Dynamic Models - -""" +title("Dynamic Models") # ╔═╡ 6107b57e-cda2-46fb-b6f8-bd0e3787516d PlutoUI.TableOfContents() @@ -67,7 +64,7 @@ md""" # ╔═╡ 2728b7c8-d294-11ef-06e6-5329a76c16be md""" -$(section_outline("Challenge:", "Tracking of Cart Position"; color="red")) +$(challenge_statement("Tracking of Cart Position"; color="red")) ##### Problem @@ -427,7 +424,7 @@ V_t &= \left(I-K_t C \right) P_{t} \tag{posterior state variance} # ╔═╡ 272a0d3a-d294-11ef-2537-39a6e410e56b md""" -$(section_outline("Challenge Revisited:", "Tracking of Cart Position"; color="green")) +$(challenge_solution("Tracking of Cart Position"; color="green")) ##### Inference by explicit Kalman filtering @@ -562,7 +559,7 @@ Given the Markov property p(x_n|x_{n-1},x_{n-2},\ldots,x_1) = p(x_n|x_{n-1}) \tag{A1} ``` -proof that, for any ``n``, +Prove that, for any ``n``, ```math \begin{align} @@ -576,7 +573,7 @@ In statistics and machine learning, the **Markov blanket** of a set of random va """ # ╔═╡ e8cab5ea-4906-4c64-b1bb-f33e267762a1 -details("Click for proof", +hide_proof( md""" First, we rewrite (A2) as @@ -833,22 +830,20 @@ md""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" RxInfer = "86711068-29c9-4ff7-b620-ae75d7495b3d" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.118" Images = "~0.26.1" LaTeXStrings = "~1.4.0" Plots = "~1.40.10" -PlutoTeachingTools = "~0.4.2" -PlutoUI = "~0.7.68" RxInfer = "~4.5.0" """ @@ -856,9 +851,9 @@ RxInfer = "~4.5.0" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "77ae6d4da195960e9acd0b80642cf4dafce8b625" +project_hash = "c4b417c8923c4c30aabaefeeeef41f3820c5b8c2" [[deps.ADTypes]] git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" @@ -1022,6 +1017,12 @@ version = "1.7.0" Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1239,9 +1240,9 @@ version = "1.15.1" [[deps.DifferentiationInterface]] deps = ["ADTypes", "LinearAlgebra"] -git-tree-sha1 = "53970db0989d231937cd96c0b0ace67f38da274e" +git-tree-sha1 = "38989b1532a3c6e2341d52b77c5475c42c3318a8" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.5" +version = "0.7.6" [deps.DifferentiationInterface.extensions] DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" @@ -1597,9 +1598,9 @@ version = "1.3.15+0" [[deps.Graphs]] deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "c5abfa0ae0aaee162a3fbb053c13ecda39be545b" +git-tree-sha1 = "7a98c6502f4632dbe9fb1973a4244eaa3324e84d" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" -version = "1.13.0" +version = "1.13.1" [[deps.Grisu]] git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2" @@ -2247,7 +2248,7 @@ version = "2.5.4+0" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] diff --git a/lectures/Factor Graphs.jl b/lectures/Factor Graphs.jl index a99143a2..4a880205 100644 --- a/lectures/Factor Graphs.jl +++ b/lectures/Factor Graphs.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/ffg-example-1.png?raw=true" @@ -19,16 +19,10 @@ using Plots, LinearAlgebra, LaTeXStrings using RxInfer, Random # ╔═╡ 5a8dcadb-f0c2-4fb0-b8cd-db8cf49cc292 -using PlutoUI, PlutoTeachingTools - -# ╔═╡ 981b08cc-7fb4-4880-8e8a-0b60a5dd72a2 -using HypertextLiteral +using BmlipTeachingTools # ╔═╡ 96547560-d294-11ef-0fa7-6b6489f7baba -md""" -# Factor Graphs - -""" +title("Factor Graphs") # ╔═╡ af24aa27-b0a1-4c9b-aee0-0e5143d2f47e PlutoUI.TableOfContents() @@ -753,7 +747,7 @@ md""" """ # ╔═╡ 206c34b3-1873-460b-911e-f2cd4f8886af -details("Click for solution", +hide_solution( md""" - (a) Rewrite the state-space equations as a set of conditional probability distributions. @@ -861,7 +855,7 @@ f_+(x,y,z) = \delta(z-x-y) """) # ╔═╡ e8a35c28-6d6d-4066-8251-f091f28622a9 -details("Click for solution", +hide_solution( md""" We use the sum-product rule to compute @@ -1096,24 +1090,23 @@ md""" # Appendix """ +# ╔═╡ 981b08cc-7fb4-4880-8e8a-0b60a5dd72a2 + + # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RxInfer = "86711068-29c9-4ff7-b620-ae75d7495b3d" [compat] -HypertextLiteral = "~0.9.5" +BmlipTeachingTools = "~1.1.0" LaTeXStrings = "~1.4.0" Plots = "~1.40.13" -PlutoTeachingTools = "~0.3.1" -PlutoUI = "~0.7.62" RxInfer = "~4.4.2" """ @@ -1121,14 +1114,14 @@ RxInfer = "~4.4.2" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "aacc534113e47e6438eb875663f1139a4ac160cd" +project_hash = "2c267c977cf5e1509686d4affec06b6e95203285" [[deps.ADTypes]] -git-tree-sha1 = "7927b9af540ee964cc5d1b73293f1eb0b761a3a1" +git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.16.0" +version = "1.17.0" [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" @@ -1264,6 +1257,12 @@ version = "1.7.0" Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1271,10 +1270,10 @@ uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" version = "1.0.9+0" [[deps.CPUSummary]] -deps = ["CpuId", "IfElse", "PrecompileTools", "Static"] -git-tree-sha1 = "5a97e67919535d6841172016c9530fd69494e5ec" +deps = ["CpuId", "IfElse", "PrecompileTools", "Preferences", "Static"] +git-tree-sha1 = "f3a21d7fc84ba618a779d1ed2fcca2e682865bab" uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" -version = "0.2.6" +version = "0.2.7" [[deps.Cairo_jll]] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] @@ -1288,12 +1287,6 @@ git-tree-sha1 = "05ba0d07cd4fd8b7a39541e31a7b0254704ea581" uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" version = "0.1.13" -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "5ac098a7c8660e217ffac31dc2af0964a8c3182a" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "2.0.0" - [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9" @@ -1358,11 +1351,6 @@ weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] CompatLinearAlgebraExt = "LinearAlgebra" -[[deps.Compiler]] -git-tree-sha1 = "382d79bfe72a406294faca39ef0c3cef6e6ce1f1" -uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" -version = "0.1.1" - [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" @@ -1459,9 +1447,9 @@ version = "1.15.1" [[deps.DifferentiationInterface]] deps = ["ADTypes", "LinearAlgebra"] -git-tree-sha1 = "f620da805b82bec64ab4d5f881c7592c82dbc08a" +git-tree-sha1 = "38989b1532a3c6e2341d52b77c5475c42c3318a8" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.3" +version = "0.7.6" [deps.DifferentiationInterface.extensions] DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" @@ -1643,9 +1631,9 @@ weakdeps = ["PDMats", "SparseArrays", "Statistics"] [[deps.FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Setfield"] -git-tree-sha1 = "f089ab1f834470c525562030c8cfde4025d5e915" +git-tree-sha1 = "31fd32af86234b6b71add76229d53129aa1b87a9" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.27.0" +version = "2.28.1" [deps.FiniteDiff.extensions] FiniteDiffBandedMatricesExt = "BandedMatrices" @@ -1770,9 +1758,9 @@ version = "1.3.15+0" [[deps.Graphs]] deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "c5abfa0ae0aaee162a3fbb053c13ecda39be545b" +git-tree-sha1 = "7a98c6502f4632dbe9fb1973a4244eaa3324e84d" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" -version = "1.13.0" +version = "1.13.1" [[deps.Grisu]] git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2" @@ -1907,12 +1895,6 @@ git-tree-sha1 = "eac1206917768cb54957c65a615460d87b455fc1" uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" version = "3.1.1+0" -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "e09121f4c523d8d8d9226acbed9cb66df515fcf2" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.4" - [[deps.LAME_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "059aabebaa7c82ccb853dd4a0ee9d17796f7e1bc" @@ -1944,9 +1926,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -2101,12 +2083,6 @@ version = "0.12.172" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" -[[deps.LoweredCodeUtils]] -deps = ["CodeTracking", "Compiler", "JuliaInterpreter"] -git-tree-sha1 = "73b98709ad811a6f81d84e105f4f695c229385ba" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.4.3" - [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" @@ -2213,7 +2189,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2223,9 +2199,9 @@ version = "1.5.0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "87510f7292a2b21aeff97912b0898f9553cc5c2c" +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.1+0" +version = "3.5.2+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] @@ -2314,9 +2290,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "3db9167c618b290a05d4345ca70de6d95304a32a" +git-tree-sha1 = "9a9216c0cf706cb2cc58fd194878180e3e51e8c0" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.17" +version = "1.40.18" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -2332,29 +2308,17 @@ version = "1.40.17" ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -[[deps.PlutoHooks]] -deps = ["InteractiveUtils", "Markdown", "UUIDs"] -git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" -version = "0.0.5" - -[[deps.PlutoLinks]] -deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] -git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" -version = "0.1.6" - [[deps.PlutoTeachingTools]] -deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoLinks", "PlutoUI"] -git-tree-sha1 = "8252b5de1f81dc103eb0293523ddf917695adea1" +deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.3.1" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "ec9e63bd098c50e4ad28e7cb95ca7a4860603298" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.68" +version = "0.7.70" [[deps.PolyaGammaHybridSamplers]] deps = ["Distributions", "Random", "SpecialFunctions", "StatsFuns"] @@ -2382,9 +2346,9 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.PrettyTables]] deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] @@ -2499,16 +2463,6 @@ git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.3.1" -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"] -git-tree-sha1 = "20ccb7e2501e9da93fe8450d01aeabf16a5f0c82" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.8.1" -weakdeps = ["Distributed"] - - [deps.Revise.extensions] - DistributedExt = "Distributed" - [[deps.Rmath]] deps = ["Random", "Rmath_jll"] git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4" @@ -2594,9 +2548,9 @@ version = "1.2.0" [[deps.SimpleTraits]] deps = ["InteractiveUtils", "MacroTools"] -git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231" +git-tree-sha1 = "be8eeac05ec97d379347584fa9fe2f5f76795bcb" uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" -version = "0.9.4" +version = "0.9.5" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -2604,9 +2558,9 @@ version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085" +git-tree-sha1 = "64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.2.1" +version = "1.2.2" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -2685,9 +2639,9 @@ version = "1.7.1" [[deps.StatsBase]] deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "b81c5035922cc89c2d9523afc6c54be512411466" +git-tree-sha1 = "2c962245732371acd51700dbb268af311bddd719" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.5" +version = "0.34.6" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -2772,9 +2726,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.11.3" [[deps.Tricks]] -git-tree-sha1 = "0fc001395447da85495b7fef1dfae9789fdd6e31" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.11" +version = "0.1.12" [[deps.Tullio]] deps = ["DiffRules", "LinearAlgebra", "Requires"] @@ -2826,9 +2780,9 @@ version = "0.4.1" [[deps.Unitful]] deps = ["Dates", "LinearAlgebra", "Random"] -git-tree-sha1 = "d2282232f8a4d71f79e85dc4dd45e5b12a6297fb" +git-tree-sha1 = "6258d453843c466d84c17a58732dda5deeb8d3af" uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "1.23.1" +version = "1.24.0" [deps.Unitful.extensions] ConstructionBaseUnitfulExt = "ConstructionBase" diff --git a/lectures/Generative Classification.jl b/lectures/Generative Classification.jl index fb775799..667d3e71 100644 --- a/lectures/Generative Classification.jl +++ b/lectures/Generative Classification.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> description = "Can you teach a computer to tell apples from peaches? Discover generative classification!" @@ -24,27 +24,16 @@ macro bind(def, element) end # ╔═╡ f1a40378-a27c-4aa0-a62c-600ffde0032f -using PlutoUI, PlutoTeachingTools - -# ╔═╡ 1b304964-6833-4cae-b84e-a5073f9586cd -using Markdown - -# ╔═╡ 05ccf8cf-0711-4751-b378-5b0953eeedd0 -using InteractiveUtils - -# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). +using BmlipTeachingTools # ╔═╡ 6631c0e4-4941-442e-8dd4-fa307ee7a8c0 using Random # ╔═╡ f1575443-c9fb-4674-bbce-bf3a5a6d5a8d -using Plots, Distributions, HypertextLiteral +using Plots, Distributions # ╔═╡ 23c689fc-d294-11ef-086e-47c4f871bed2 -md""" -# Generative Classification - -""" +title("Generative Classification") # ╔═╡ fe9d4fbc-f264-459b-8fbe-26663500f6c5 PlutoUI.TableOfContents() @@ -69,7 +58,7 @@ md""" """ # ╔═╡ f7a19975-a919-4659-9b6a-d8963a1cd6d9 -section_outline("Challenge:", "Apple or Peach?" , color= "red" ) +challenge_statement("Apple or Peach?" , color= "red" ) # ╔═╡ 51a46b5e-0c35-4841-a4f3-413d5d294805 md""" @@ -196,7 +185,7 @@ In principle, a full Bayesian treatment requires us to specify prior distributio """ # ╔═╡ ffc80e65-a454-4b45-a9b7-76b01c7e96c0 -section_outline("Exercise:", "Evaluate log-likelihood" , color= "yellow", header_level=4 ) +exercise_statement("Evaluate log-likelihood" , color= "yellow", header_level=4 ) # ╔═╡ 2e1ccf78-6097-4097-8bc8-1f1ec2d9c3ff md""" @@ -212,7 +201,7 @@ where we used ``m_k \triangleq \sum_n y_{nk}``. """ # ╔═╡ 32cb67f6-1ed2-4d30-8493-e4eed9651526 -details("Click for answer", +hide_solution( md""" ```math \begin{align*} @@ -384,7 +373,7 @@ are lines (hyperplanes) in the feature space. """ # ╔═╡ 5c746070-19a9-464b-aedc-401d016dfdb6 -section_outline("Exercise:", "Discrimination boundaries" , color= "yellow", header_level=4 ) +exercise_statement("Discrimination boundaries" , color= "yellow", header_level=4 ) # ╔═╡ 8d78f9d3-7ba8-46b0-8d6f-231e681caa49 md""" @@ -392,7 +381,7 @@ Show that the discrimination boundaries for the posterior class probabilities in """ # ╔═╡ 25e18c78-9cac-4faa-bb7c-ac036d0eac90 -details("Click for answer", +hide_solution( md""" ```math \begin{align} @@ -419,7 +408,7 @@ What do the decision boundaries look like in this case? """ # ╔═╡ b01a4a56-bed2-4a06-991a-831adc84aa3e -details("Click for answer", +hide_solution( md""" Following the same derivation as above (in the cell "Click for proof of (4)"), the posterior class probability evaluates to ```math @@ -432,7 +421,7 @@ Because the quadratic term ``x_\bullet^T \hat{\Sigma}_k^{-1} x_\bullet`` is now """ ) # ╔═╡ 1a890e4b-b8a9-4a6e-b1f3-17863e1416d7 -section_outline("Challenge Revisited:", "Apple or Peach", header_level=2, color="green") +challenge_solution("Apple or Peach", header_level=2, color="green") # ╔═╡ 23c82e10-d294-11ef-286a-ff6fee0f2805 md""" @@ -590,7 +579,7 @@ Compute the **total** error probability ``p(\text{error})`` for the Bayes class """ # ╔═╡ 66172ab6-7df8-4068-a748-b33b3f345d6d -details("Click for solution", +hide_solution( md""" - (a) We choose ``C_1`` if ``p(C_1|x)/p(C_2|x) > 1``. This condition can be worked out as @@ -643,7 +632,7 @@ Using (4.57) and (4.58) (from Bishop's book), derive the result (4.65) for the p """ # ╔═╡ ef1e5885-7153-4b55-9f97-1e984c2504e6 -details("Click for solution", +hide_solution( md""" Substitute 4.64 into 4.58 to get @@ -665,18 +654,6 @@ md""" # Appendix """ -# ╔═╡ 3804c03c-6769-4258-806a-62e3d18221b5 -macro bind(def, element) - #! format: off - return quote - local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end - local el = $(esc(element)) - global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) - el - end - #! format: on -end - # ╔═╡ 86f217fc-379c-46a0-a720-de956d456b2a md""" ## Code @@ -730,9 +707,6 @@ d1 = fit_mle(FullNormal, X_apples') # MLE density estimation d1 = N(μ₁, Σ # ╔═╡ cd310392-aabd-40e0-b06f-f8297c7eed6f d2 = fit_mle(FullNormal, X_peaches') # MLE density estimation d2 = N(μ₂, Σ₂) -# ╔═╡ ba9fa93f-093c-4783-988f-27f4ba228e88 -Σ_computed = π_hat[1]*cov(d1) + π_hat[2]*cov(d2) # Combine Σ₁ and Σ₂ into Σ - # ╔═╡ 46d2d5e9-bb6b-409a-acdc-cdffd1a6f797 conditionals = [ MvNormal(mean(d1), Σ_computed) @@ -790,33 +764,33 @@ let plot!(x1, discriminant_x2, fillrange=10, alpha=0.2, color=:red, xlims=(-0.5, 3), ylims=(-1, 4), label="") end +# ╔═╡ ba9fa93f-093c-4783-988f-27f4ba228e88 +Σ_computed = Σ = π_hat[1]*cov(d1) + π_hat[2]*cov(d2) # Combine Σ₁ and Σ₂ into Σ + +# ╔═╡ aefc2f7d-96ed-45cc-b2d9-35d9b2a94f45 +Σ = Σ_computed; + # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.120" -HypertextLiteral = "~0.9.5" -Plots = "~1.40.17" -PlutoTeachingTools = "~0.4.4" -PlutoUI = "~0.7.62" +Plots = "~1.40.18" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "def3744cfb9ac0d0939e72d808a6a7f037d39060" +project_hash = "fc70636cdfa8aaa33082903a96453a1611278503" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -847,6 +821,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -897,16 +877,6 @@ git-tree-sha1 = "37ea44092930b1811e666c3bc38065d7d87fcc74" uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" version = "0.13.1" -[[deps.Compat]] -deps = ["TOML", "UUIDs"] -git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.18.0" -weakdeps = ["Dates", "LinearAlgebra"] - - [deps.Compat.extensions] - CompatLinearAlgebraExt = "LinearAlgebra" - [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" @@ -929,10 +899,10 @@ uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" version = "1.16.0" [[deps.DataStructures]] -deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "4e1fe97fdaed23e9dc21d4d664bea76b65fc50a0" +deps = ["OrderedCollections"] +git-tree-sha1 = "76b3b7c3925d943edf158ddb7f693ba54eb297a5" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.22" +version = "0.19.0" [[deps.Dates]] deps = ["Printf"] @@ -1194,9 +1164,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -1375,7 +1345,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -1385,9 +1355,9 @@ version = "1.5.0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "87510f7292a2b21aeff97912b0898f9553cc5c2c" +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.1+0" +version = "3.5.2+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] @@ -1458,9 +1428,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "3db9167c618b290a05d4345ca70de6d95304a32a" +git-tree-sha1 = "9a9216c0cf706cb2cc58fd194878180e3e51e8c0" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.17" +version = "1.40.18" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -1478,15 +1448,15 @@ version = "1.40.17" [[deps.PlutoTeachingTools]] deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] -git-tree-sha1 = "d0f6e09433d14161a24607268d89be104e743523" +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.4.4" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "ec9e63bd098c50e4ad28e7cb95ca7a4860603298" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.68" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -1496,9 +1466,9 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] @@ -1628,9 +1598,9 @@ version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085" +git-tree-sha1 = "64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.2.1" +version = "1.2.2" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -1673,9 +1643,9 @@ version = "1.7.1" [[deps.StatsBase]] deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "b81c5035922cc89c2d9523afc6c54be512411466" +git-tree-sha1 = "2c962245732371acd51700dbb268af311bddd719" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.5" +version = "0.34.6" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -1731,9 +1701,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.11.3" [[deps.Tricks]] -git-tree-sha1 = "0fc001395447da85495b7fef1dfae9789fdd6e31" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.11" +version = "0.1.12" [[deps.URIs]] git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a" @@ -2058,7 +2028,7 @@ version = "1.9.2+0" # ╟─f7a19975-a919-4659-9b6a-d8963a1cd6d9 # ╟─51a46b5e-0c35-4841-a4f3-413d5d294805 # ╟─876f47d8-b272-4e23-b5ec-5c7d615ff618 -# ╟─69732524-90fd-46f4-9706-c07ce6226d2b +# ╠═69732524-90fd-46f4-9706-c07ce6226d2b # ╟─e774041a-672d-40f3-ac8f-fc5dbf1bfc59 # ╟─5730758d-80cd-4d95-b16c-399c38cf585b # ╟─23c73302-d294-11ef-0c12-571686b202a9 @@ -2101,6 +2071,7 @@ version = "1.9.2+0" # ╠═33d5d6e7-1208-4c5b-b651-429b3b6ad50b # ╠═723e09fc-ec63-4c47-844c-d821515ce0f4 # ╟─3791ac2a-8dc2-4d9a-8310-beae13d5a694 +# ╠═aefc2f7d-96ed-45cc-b2d9-35d9b2a94f45 # ╠═b06c93fa-3439-4ed1-84ed-befc1ab7e40b # ╠═8610196d-2e0b-4a7f-96b2-2ca09078ffd6 # ╠═25002ffd-79c9-44bf-85d8-28c87df6c9df @@ -2118,12 +2089,9 @@ version = "1.9.2+0" # ╟─ef1e5885-7153-4b55-9f97-1e984c2504e6 # ╟─e65e0e33-3e4f-4765-84ea-a4fb5d43269e # ╠═f1a40378-a27c-4aa0-a62c-600ffde0032f -# ╠═1b304964-6833-4cae-b84e-a5073f9586cd -# ╠═05ccf8cf-0711-4751-b378-5b0953eeedd0 -# ╠═3804c03c-6769-4258-806a-62e3d18221b5 # ╠═6631c0e4-4941-442e-8dd4-fa307ee7a8c0 # ╠═f1575443-c9fb-4674-bbce-bf3a5a6d5a8d -# ╠═86f217fc-379c-46a0-a720-de956d456b2a +# ╟─86f217fc-379c-46a0-a720-de956d456b2a # ╟─a4463d74-04ea-428a-b5a5-504d96432a0a # ╠═3842654e-6dd7-427c-bb77-8b35a2f324fb # ╠═eac2821e-b25c-4605-857a-cd3bd06303c1 diff --git a/lectures/Intelligent Agents and Active Inference-2024.jl b/lectures/Intelligent Agents and Active Inference-2024.jl index a8c13b44..36bfd619 100644 --- a/lectures/Intelligent Agents and Active Inference-2024.jl +++ b/lectures/Intelligent Agents and Active Inference-2024.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/ai_agent/agent-cart-interaction2.png?raw=true" @@ -992,7 +992,7 @@ RxInfer = "86711068-29c9-4ff7-b620-ae75d7495b3d" [compat] HypergeometricFunctions = "~0.3.28" Plots = "~1.40.13" -PlutoTeachingTools = "~0.3.1" +PlutoTeachingTools = "~0.4.5" PlutoUI = "~0.7.62" RxInfer = "~4.4.2" """ @@ -1001,14 +1001,14 @@ RxInfer = "~4.4.2" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "3f693e23898dd5e5331d626a7b75858da8dd63a2" +project_hash = "3e8d9cf514368ff08e955aff49240e67bb0e4062" [[deps.ADTypes]] -git-tree-sha1 = "7927b9af540ee964cc5d1b73293f1eb0b761a3a1" +git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.16.0" +version = "1.17.0" [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" @@ -1151,10 +1151,10 @@ uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" version = "1.0.9+0" [[deps.CPUSummary]] -deps = ["CpuId", "IfElse", "PrecompileTools", "Static"] -git-tree-sha1 = "5a97e67919535d6841172016c9530fd69494e5ec" +deps = ["CpuId", "IfElse", "PrecompileTools", "Preferences", "Static"] +git-tree-sha1 = "f3a21d7fc84ba618a779d1ed2fcca2e682865bab" uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" -version = "0.2.6" +version = "0.2.7" [[deps.Cairo_jll]] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] @@ -1168,12 +1168,6 @@ git-tree-sha1 = "05ba0d07cd4fd8b7a39541e31a7b0254704ea581" uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" version = "0.1.13" -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "5ac098a7c8660e217ffac31dc2af0964a8c3182a" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "2.0.0" - [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9" @@ -1238,11 +1232,6 @@ weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] CompatLinearAlgebraExt = "LinearAlgebra" -[[deps.Compiler]] -git-tree-sha1 = "382d79bfe72a406294faca39ef0c3cef6e6ce1f1" -uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" -version = "0.1.1" - [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" @@ -1339,9 +1328,9 @@ version = "1.15.1" [[deps.DifferentiationInterface]] deps = ["ADTypes", "LinearAlgebra"] -git-tree-sha1 = "54d7b8c74408048aea9c055ac8573b2b5c5ec11f" +git-tree-sha1 = "38989b1532a3c6e2341d52b77c5475c42c3318a8" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.4" +version = "0.7.6" [deps.DifferentiationInterface.extensions] DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" @@ -1523,9 +1512,9 @@ weakdeps = ["PDMats", "SparseArrays", "Statistics"] [[deps.FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Setfield"] -git-tree-sha1 = "f089ab1f834470c525562030c8cfde4025d5e915" +git-tree-sha1 = "31fd32af86234b6b71add76229d53129aa1b87a9" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.27.0" +version = "2.28.1" [deps.FiniteDiff.extensions] FiniteDiffBandedMatricesExt = "BandedMatrices" @@ -1650,9 +1639,9 @@ version = "1.3.15+0" [[deps.Graphs]] deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "c5abfa0ae0aaee162a3fbb053c13ecda39be545b" +git-tree-sha1 = "7a98c6502f4632dbe9fb1973a4244eaa3324e84d" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" -version = "1.13.0" +version = "1.13.1" [[deps.Grisu]] git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2" @@ -1787,12 +1776,6 @@ git-tree-sha1 = "eac1206917768cb54957c65a615460d87b455fc1" uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" version = "3.1.1+0" -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "e09121f4c523d8d8d9226acbed9cb66df515fcf2" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.4" - [[deps.LAME_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "059aabebaa7c82ccb853dd4a0ee9d17796f7e1bc" @@ -1824,9 +1807,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -1981,12 +1964,6 @@ version = "0.12.172" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" -[[deps.LoweredCodeUtils]] -deps = ["CodeTracking", "Compiler", "JuliaInterpreter"] -git-tree-sha1 = "73b98709ad811a6f81d84e105f4f695c229385ba" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.4.3" - [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" @@ -2093,7 +2070,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2103,9 +2080,9 @@ version = "1.5.0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "87510f7292a2b21aeff97912b0898f9553cc5c2c" +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.1+0" +version = "3.5.2+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] @@ -2194,9 +2171,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "3db9167c618b290a05d4345ca70de6d95304a32a" +git-tree-sha1 = "9a9216c0cf706cb2cc58fd194878180e3e51e8c0" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.17" +version = "1.40.18" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -2212,29 +2189,17 @@ version = "1.40.17" ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -[[deps.PlutoHooks]] -deps = ["InteractiveUtils", "Markdown", "UUIDs"] -git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" -version = "0.0.5" - -[[deps.PlutoLinks]] -deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] -git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" -version = "0.1.6" - [[deps.PlutoTeachingTools]] -deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoLinks", "PlutoUI"] -git-tree-sha1 = "8252b5de1f81dc103eb0293523ddf917695adea1" +deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.3.1" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PolyaGammaHybridSamplers]] deps = ["Distributions", "Random", "SpecialFunctions", "StatsFuns"] @@ -2262,9 +2227,9 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.PrettyTables]] deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] @@ -2379,16 +2344,6 @@ git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.3.1" -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"] -git-tree-sha1 = "20ccb7e2501e9da93fe8450d01aeabf16a5f0c82" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.8.1" -weakdeps = ["Distributed"] - - [deps.Revise.extensions] - DistributedExt = "Distributed" - [[deps.Rmath]] deps = ["Random", "Rmath_jll"] git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4" @@ -2474,9 +2429,9 @@ version = "1.2.0" [[deps.SimpleTraits]] deps = ["InteractiveUtils", "MacroTools"] -git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231" +git-tree-sha1 = "be8eeac05ec97d379347584fa9fe2f5f76795bcb" uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" -version = "0.9.4" +version = "0.9.5" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -2484,9 +2439,9 @@ version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085" +git-tree-sha1 = "64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.2.1" +version = "1.2.2" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -2565,9 +2520,9 @@ version = "1.7.1" [[deps.StatsBase]] deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "b81c5035922cc89c2d9523afc6c54be512411466" +git-tree-sha1 = "2c962245732371acd51700dbb268af311bddd719" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.5" +version = "0.34.6" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -2652,9 +2607,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.11.3" [[deps.Tricks]] -git-tree-sha1 = "0fc001395447da85495b7fef1dfae9789fdd6e31" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.11" +version = "0.1.12" [[deps.Tullio]] deps = ["DiffRules", "LinearAlgebra", "Requires"] diff --git a/lectures/Intelligent Agents and Active Inference.jl b/lectures/Intelligent Agents and Active Inference.jl index 6b240af7..15186b8e 100644 --- a/lectures/Intelligent Agents and Active Inference.jl +++ b/lectures/Intelligent Agents and Active Inference.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/ai_agent/agent-cart-interaction2.png?raw=true" @@ -16,13 +16,10 @@ using InteractiveUtils using LinearAlgebra, Plots, RxInfer # ╔═╡ 97a0384a-0596-4714-a3fc-bf422aed4474 -using PlutoUI, PlutoTeachingTools, HypertextLiteral +using BmlipTeachingTools # ╔═╡ 278382c0-d294-11ef-022f-0d78e9e2d04c -md""" -# Intelligent Agents and Active Inference - -""" +title("Intelligent Agents and Active Inference") # ╔═╡ 9fbae8bf-2132-4a9a-ab0b-ef99e1b954a4 PlutoUI.TableOfContents() @@ -81,7 +78,7 @@ In this lesson, we will describe how **goal-directed behavior** by biological (a """ # ╔═╡ aed436fd-6773-4932-a5d8-d01cf99c10ec -section_outline("Challenge:", "The Mountain Car Problem", color="red") +challenge_statement("The Mountain Car Problem", color="red") # ╔═╡ 2783b312-d294-11ef-2ebb-e5ede7a86583 md""" @@ -426,7 +423,7 @@ md""" """ # ╔═╡ 64474167-bf52-456c-9099-def288bd17bf -section_outline("Challenge Revisited:", "The Mountain Car Problem", color="green") +challenge_solution("The Mountain Car Problem", color="green") # ╔═╡ 2784f45e-d294-11ef-0439-1903016c1f14 md""" @@ -921,20 +918,16 @@ end # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" HypergeometricFunctions = "34004b35-14d8-5ef3-9330-4cdb6864b03a" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" RxInfer = "86711068-29c9-4ff7-b620-ae75d7495b3d" [compat] +BmlipTeachingTools = "~1.1.0" HypergeometricFunctions = "~0.3.28" -HypertextLiteral = "~0.9.5" Plots = "~1.40.13" -PlutoTeachingTools = "~0.4.4" -PlutoUI = "~0.7.62" RxInfer = "~4.4.2" """ @@ -942,14 +935,14 @@ RxInfer = "~4.4.2" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "011199c8023b6f8ac4406f6c30e2d15f624a3762" +project_hash = "f58e5307e6a89686f632ef82f9f537f006df12b1" [[deps.ADTypes]] -git-tree-sha1 = "7927b9af540ee964cc5d1b73293f1eb0b761a3a1" +git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.16.0" +version = "1.17.0" [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" @@ -1085,6 +1078,12 @@ version = "1.7.0" Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" BandedMatrices = "aae01518-5342-5314-be14-df237901396f" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1092,10 +1091,10 @@ uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" version = "1.0.9+0" [[deps.CPUSummary]] -deps = ["CpuId", "IfElse", "PrecompileTools", "Static"] -git-tree-sha1 = "5a97e67919535d6841172016c9530fd69494e5ec" +deps = ["CpuId", "IfElse", "PrecompileTools", "Preferences", "Static"] +git-tree-sha1 = "f3a21d7fc84ba618a779d1ed2fcca2e682865bab" uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" -version = "0.2.6" +version = "0.2.7" [[deps.Cairo_jll]] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] @@ -1269,9 +1268,9 @@ version = "1.15.1" [[deps.DifferentiationInterface]] deps = ["ADTypes", "LinearAlgebra"] -git-tree-sha1 = "54d7b8c74408048aea9c055ac8573b2b5c5ec11f" +git-tree-sha1 = "38989b1532a3c6e2341d52b77c5475c42c3318a8" uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" -version = "0.7.4" +version = "0.7.6" [deps.DifferentiationInterface.extensions] DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" @@ -1453,9 +1452,9 @@ weakdeps = ["PDMats", "SparseArrays", "Statistics"] [[deps.FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Setfield"] -git-tree-sha1 = "f089ab1f834470c525562030c8cfde4025d5e915" +git-tree-sha1 = "31fd32af86234b6b71add76229d53129aa1b87a9" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.27.0" +version = "2.28.1" [deps.FiniteDiff.extensions] FiniteDiffBandedMatricesExt = "BandedMatrices" @@ -1580,9 +1579,9 @@ version = "1.3.15+0" [[deps.Graphs]] deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"] -git-tree-sha1 = "c5abfa0ae0aaee162a3fbb053c13ecda39be545b" +git-tree-sha1 = "7a98c6502f4632dbe9fb1973a4244eaa3324e84d" uuid = "86223c79-3864-5bf0-83f7-82e725a168b6" -version = "1.13.0" +version = "1.13.1" [[deps.Grisu]] git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2" @@ -1748,9 +1747,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -2011,7 +2010,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2021,9 +2020,9 @@ version = "1.5.0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "87510f7292a2b21aeff97912b0898f9553cc5c2c" +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.1+0" +version = "3.5.2+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] @@ -2112,9 +2111,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "3db9167c618b290a05d4345ca70de6d95304a32a" +git-tree-sha1 = "9a9216c0cf706cb2cc58fd194878180e3e51e8c0" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.17" +version = "1.40.18" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -2132,15 +2131,15 @@ version = "1.40.17" [[deps.PlutoTeachingTools]] deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] -git-tree-sha1 = "d0f6e09433d14161a24607268d89be104e743523" +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.4.4" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PolyaGammaHybridSamplers]] deps = ["Distributions", "Random", "SpecialFunctions", "StatsFuns"] @@ -2168,9 +2167,9 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.PrettyTables]] deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] @@ -2370,9 +2369,9 @@ version = "1.2.0" [[deps.SimpleTraits]] deps = ["InteractiveUtils", "MacroTools"] -git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231" +git-tree-sha1 = "be8eeac05ec97d379347584fa9fe2f5f76795bcb" uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" -version = "0.9.4" +version = "0.9.5" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" @@ -2548,9 +2547,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.11.3" [[deps.Tricks]] -git-tree-sha1 = "0fc001395447da85495b7fef1dfae9789fdd6e31" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.11" +version = "0.1.12" [[deps.Tullio]] deps = ["DiffRules", "LinearAlgebra", "Requires"] diff --git a/lectures/Latent Variable Models and VB.jl b/lectures/Latent Variable Models and VB.jl index 3ed6151d..bc938466 100644 --- a/lectures/Latent Variable Models and VB.jl +++ b/lectures/Latent Variable Models and VB.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/fig-Bishop-A5-Old-Faithfull.png?raw=true" @@ -16,19 +16,13 @@ using InteractiveUtils using LinearAlgebra, PDMats, SpecialFunctions, Random # ╔═╡ df171940-eb54-48e2-a2b8-1a8162cabf3e -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 58bd0d43-743c-4745-b353-4a89b35e85ba using Distributions, Plots, StatsPlots -# ╔═╡ 9d2068d7-db54-460e-930c-b7c3273162ee -using HypertextLiteral - # ╔═╡ 26c56fd8-d294-11ef-236d-81deef63f37c -md""" -# Latent Variable Models and Variational Bayes - -""" +title("Latent Variable Models and Variational Bayes") # ╔═╡ ce7d086b-ff20-4da1-a4e8-52b5b7dc9e2b PlutoUI.TableOfContents() @@ -62,6 +56,17 @@ md""" """ +# ╔═╡ 26c591fc-d294-11ef-0423-b7a854d09bad +md""" + +$(challenge_statement("Density Modeling for the Old Faithful Data Set")) + +You're now asked to build a density model for a data set ([Old Faithful](https://en.wikipedia.org/wiki/Old_Faithful), Bishop pg. 681) that clearly is not distributed as a single Gaussian: + +![](https://github.com/bmlip/course/blob/v2/assets/figures/fig-Bishop-A5-Old-Faithfull.png?raw=true) + +""" + # ╔═╡ e0d0f3a1-5e00-44f0-9c2b-4308cbd673ce TODO("the figure above is very large; can we scale the size down a bit?") @@ -154,7 +159,7 @@ p(x_n) &= \sum_{z_n} p(x_n,z_n) \\ """ # ╔═╡ c7351bf1-447e-475b-8965-d259c01bfd57 -details("Click for proof", +hide_proof( md""" ```math @@ -312,7 +317,7 @@ To explain inference by VFE minimization (abbreviated as VFEM), we first rewrite """ # ╔═╡ ae7ed1fc-fc36-4327-be55-a142477ca0ad -details("Click for proof", +hide_proof( md""" ```math \begin{align*} @@ -588,6 +593,19 @@ Exam guide: Working out VFE minimization for the GMM to these update equations ( """ +# ╔═╡ 95d47a10-f3f8-479b-afe0-21241104b758 +code_example("VFEM for GMM on Old Faithfull data set") + + +# ╔═╡ 26c7696e-d294-11ef-25f2-dbc0946c0858 +md""" + + + +Below we exemplify training of a Gaussian Mixture Model on the Old Faithful data set by VFE minimization, with the constraints as specified above. + +""" + # ╔═╡ cc547bfa-a130-4382-af47-73de56e4741b old_faithful = # CSV.read(download("https://github.com/bmlip/course/blob/v2/assets/datasets/old_faithful.csv?raw=true"), DataFrame); @@ -1050,7 +1068,7 @@ The Free energy functional ``\mathrm{F}[q] = -\sum_z q(z) \log p(x,z) - \sum_z q """ # ╔═╡ 747a7e1e-b921-4882-b00a-1b00bef8433d -details("Click for answer", +hide_solution( md""" Note that Free Energy minimization is a balancing act: FE minimization implies entropy maximization *and at the same time* energy minimization. Minimizing the energy term leads to aligning ``q(z)`` with ``\log p(x,z)``, ie, it tries to move the bulk of the function ``q(z)`` to areas in ``z``-space where ``p(x,z)`` is large (``p(x,z)`` is here just a function of ``z``, since x is observed). @@ -1073,7 +1091,7 @@ m_k = \frac{1}{\beta_k} \left( \beta_0 m_0 + N_k \bar{x}_k \right) \tag{B-10.61} """ # ╔═╡ 208ba1bb-a4bf-4b8c-93d2-0d6c6c8d16d4 -details("Click for answer", +hide_solution( md""" We see here an example of "precision-weighted means add" when two sources of information are fused, just like precision-weighted means add when two Gaussians are multiplied, eg a prior and likelihood. In this case, the prior is ``m_0`` and the likelihood estimate is ``\bar{x}``. ``\beta_0`` can be interpreted as the number of pseudo-observations in the prior. @@ -1092,7 +1110,7 @@ q^{(i)}(z) &= p(z|D,\theta^{(i-1)}) \\ \end{align*} ``` -Proof that this algorithm minimizes the Free Energy functional +Prove that this algorithm minimizes the Free Energy functional ```math \begin{align*} @@ -1104,7 +1122,7 @@ F[q](\theta) = \sum_z q(z) \log \frac{q(z)}{p(D,z|\theta)} """ # ╔═╡ b91bc3b6-b815-4942-b297-c0e2b4b99654 -details("Click for answer", +hide_solution( md""" Let's start with a prior estimate ``\theta^{(i-1)}`` and we want to minimize the free energy functional wrt ``q``. This leads to @@ -1627,90 +1645,29 @@ begin plot(plots..., layout=(2,3), size=(1100, 600)) end -# ╔═╡ deba376e-59bd-4b07-814c-8f7937db52a5 -challenge_header( - title; - color="green", - big::Bool=false, - header_level::Int=2, - challenge_text="Challenge:", -) = HypertextLiteral.@htl """ -<$("h$header_level") class="ptt-section $(big ? "big" : "")" style="--ptt-accent: $(color);">$(challenge_text) $(title) - - -""" - -# ╔═╡ 26c591fc-d294-11ef-0423-b7a854d09bad -md""" - -$(challenge_header("Density Modeling for the Old Faithful Data Set"; challenge_text="Challenge:")) - -You're now asked to build a density model for a data set ([Old Faithful](https://en.wikipedia.org/wiki/Old_Faithful), Bishop pg. 681) that clearly is not distributed as a single Gaussian: - -![](https://github.com/bmlip/course/blob/v2/assets/figures/fig-Bishop-A5-Old-Faithfull.png?raw=true) - -""" - -# ╔═╡ 26c7696e-d294-11ef-25f2-dbc0946c0858 -md""" - -$(challenge_header("VFEM for GMM on Old Faithfull data set"; challenge_text="Code Example:")) +# ╔═╡ 9d2068d7-db54-460e-930c-b7c3273162ee -Below we exemplify training of a Gaussian Mixture Model on the Old Faithful data set by VFE minimization, with the constraints as specified above. +# ╔═╡ deba376e-59bd-4b07-814c-8f7937db52a5 -""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.118" -HypertextLiteral = "~0.9.5" PDMats = "~0.11.32" Plots = "~1.40.10" -PlutoTeachingTools = "~0.3.1" -PlutoUI = "~0.7.23" SpecialFunctions = "~2.5.0" StatsPlots = "~0.15.7" """ @@ -1719,9 +1676,9 @@ StatsPlots = "~0.15.7" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "59e8044d279caf7d25835d1497116e8f1412478f" +project_hash = "5fbaba1f25045f81a3ec3163b3be43339a946399" [[deps.AbstractFFTs]] deps = ["LinearAlgebra"] @@ -1792,6 +1749,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1806,9 +1769,9 @@ version = "1.18.5+0" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] -git-tree-sha1 = "06ee8d1aa558d2833aa799f6f0b31b30cada405f" +git-tree-sha1 = "e4c6a16e77171a5f5e25e9646617ab1c276c5607" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.25.2" +version = "1.26.0" weakdeps = ["SparseArrays"] [deps.ChainRulesCore.extensions] @@ -1820,12 +1783,6 @@ git-tree-sha1 = "3e22db924e2945282e70c33b75d4dde8bfa44c94" uuid = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5" version = "0.15.8" -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "062c5e1a5bf6ada13db96a4ae4749a4c2234f521" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "1.3.9" - [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9" @@ -1866,19 +1823,14 @@ version = "0.13.1" [[deps.Compat]] deps = ["TOML", "UUIDs"] -git-tree-sha1 = "3a3dfb30697e96a440e4149c8c51bf32f818c0f3" +git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.17.0" +version = "4.18.0" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] CompatLinearAlgebraExt = "LinearAlgebra" -[[deps.Compiler]] -git-tree-sha1 = "382d79bfe72a406294faca39ef0c3cef6e6ce1f1" -uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" -version = "0.1.1" - [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" @@ -1990,15 +1942,15 @@ version = "2.6.5+0" [[deps.FFMPEG]] deps = ["FFMPEG_jll"] -git-tree-sha1 = "53ebe7511fa11d33bec688a9178fac4e49eeee00" +git-tree-sha1 = "83dc665d0312b41367b7263e8a4d172eac1897f4" uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" -version = "0.4.2" +version = "0.4.4" [[deps.FFMPEG_jll]] deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"] -git-tree-sha1 = "466d45dc38e15794ec7d5d63ec03d776a9aff36e" +git-tree-sha1 = "3a948313e7a41eb1db7a1e733e6335f17b4ab3c4" uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5" -version = "4.4.4+1" +version = "7.1.1+0" [[deps.FFTW]] deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"] @@ -2136,9 +2088,9 @@ version = "0.2.5" [[deps.IntelOpenMP_jll]] deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"] -git-tree-sha1 = "0f14a5456bdc6b9731a5682f439a672750a09e48" +git-tree-sha1 = "ec1debd61c300961f98064cfb21287613ad7f303" uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" -version = "2025.0.4+0" +version = "2025.2.0+0" [[deps.InteractiveUtils]] deps = ["Markdown"] @@ -2173,9 +2125,9 @@ version = "0.1.11" [[deps.JLLWrappers]] deps = ["Artifacts", "Preferences"] -git-tree-sha1 = "a007feb38b422fbdab534406aeca1b86823cb4d6" +git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.7.0" +version = "1.7.1" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -2189,12 +2141,6 @@ git-tree-sha1 = "eac1206917768cb54957c65a615460d87b455fc1" uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" version = "3.1.1+0" -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "6ac9e4acc417a5b534ace12690bc6973c25b862f" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.3" - [[deps.KernelDensity]] deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"] git-tree-sha1 = "ba51324b894edaf1df3ab16e2cc6bc3280a2f1a7" @@ -2232,9 +2178,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -2349,12 +2295,6 @@ git-tree-sha1 = "f02b56007b064fbfddb4c9cd60161b6dd0f40df3" uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" version = "1.1.0" -[[deps.LoweredCodeUtils]] -deps = ["Compiler", "JuliaInterpreter"] -git-tree-sha1 = "bc54ba0681bb71e56043a1b923028d652e78ee42" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.4.1" - [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" @@ -2362,9 +2302,9 @@ version = "1.1.0" [[deps.MKL_jll]] deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"] -git-tree-sha1 = "5de60bc6cb3899cd318d80d627560fae2e2d99ae" +git-tree-sha1 = "282cadc186e7b2ae0eeadbd7a4dffed4196ae2aa" uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" -version = "2025.0.1+1" +version = "2025.2.0+0" [[deps.MacroTools]] git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522" @@ -2420,9 +2360,9 @@ version = "1.1.3" [[deps.NearestNeighbors]] deps = ["Distances", "StaticArrays"] -git-tree-sha1 = "8a3271d8309285f4db73b4f662b1b290c715e85e" +git-tree-sha1 = "ca7e18198a166a1f3eb92a3650d53d94ed8ca8a1" uuid = "b8a86587-4115-5ab1-83bc-aa920d37bbce" -version = "0.4.21" +version = "0.4.22" [[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" @@ -2456,7 +2396,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2466,9 +2406,9 @@ version = "1.5.0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "87510f7292a2b21aeff97912b0898f9553cc5c2c" +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.5.1+0" +version = "3.5.2+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] @@ -2539,9 +2479,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "55818b50883d7141bd98cdf5fc2f4ced96ee075f" +git-tree-sha1 = "9a9216c0cf706cb2cc58fd194878180e3e51e8c0" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.16" +version = "1.40.18" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -2557,29 +2497,17 @@ version = "1.40.16" ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -[[deps.PlutoHooks]] -deps = ["InteractiveUtils", "Markdown", "UUIDs"] -git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" -version = "0.0.5" - -[[deps.PlutoLinks]] -deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] -git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" -version = "0.1.6" - [[deps.PlutoTeachingTools]] -deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoLinks", "PlutoUI"] -git-tree-sha1 = "8252b5de1f81dc103eb0293523ddf917695adea1" +deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.3.1" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "ec9e63bd098c50e4ad28e7cb95ca7a4860603298" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.68" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -2589,9 +2517,9 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] @@ -2688,16 +2616,6 @@ git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.3.1" -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"] -git-tree-sha1 = "f6f7d30fb0d61c64d0cfe56cf085a7c9e7d5bc80" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.8.0" -weakdeps = ["Distributed"] - - [deps.Revise.extensions] - DistributedExt = "Distributed" - [[deps.Rmath]] deps = ["Random", "Rmath_jll"] git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4" @@ -2752,9 +2670,9 @@ version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085" +git-tree-sha1 = "64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.2.1" +version = "1.2.2" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] @@ -2779,9 +2697,9 @@ version = "1.0.3" [[deps.StaticArrays]] deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] -git-tree-sha1 = "0feb6b9031bd5c51f9072393eb5ab3efd31bf9e4" +git-tree-sha1 = "cbea8a6bd7bed51b1619658dec70035e07b8502f" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.13" +version = "1.9.14" weakdeps = ["ChainRulesCore", "Statistics"] [deps.StaticArrays.extensions] @@ -2811,9 +2729,9 @@ version = "1.7.1" [[deps.StatsBase]] deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "b81c5035922cc89c2d9523afc6c54be512411466" +git-tree-sha1 = "2c962245732371acd51700dbb268af311bddd719" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.34.5" +version = "0.34.6" [[deps.StatsFuns]] deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] @@ -2893,9 +2811,9 @@ uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" version = "0.11.3" [[deps.Tricks]] -git-tree-sha1 = "6cae795a5a9313bbb4f60683f7263318fc7d1505" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.10" +version = "0.1.12" [[deps.URIs]] git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a" @@ -2919,9 +2837,9 @@ version = "0.4.1" [[deps.Unitful]] deps = ["Dates", "LinearAlgebra", "Random"] -git-tree-sha1 = "d2282232f8a4d71f79e85dc4dd45e5b12a6297fb" +git-tree-sha1 = "6258d453843c466d84c17a58732dda5deeb8d3af" uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "1.23.1" +version = "1.24.0" [deps.Unitful.extensions] ConstructionBaseUnitfulExt = "ConstructionBase" @@ -3139,15 +3057,15 @@ version = "0.61.1+0" [[deps.libaom_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "522c1df09d05a71785765d19c9524661234738e9" +git-tree-sha1 = "4bba74fa59ab0755167ad24f98800fe5d727175b" uuid = "a4ae2306-e953-59d6-aa16-d00cac43593b" -version = "3.11.0+0" +version = "3.12.1+0" [[deps.libass_jll]] deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Zlib_jll"] -git-tree-sha1 = "e17c115d55c5fbb7e52ebedb427a0dca79d4484e" +git-tree-sha1 = "125eedcb0a4a0bba65b657251ce1d27c8714e9d6" uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0" -version = "0.15.2+0" +version = "0.17.4+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] @@ -3213,16 +3131,16 @@ uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" version = "17.4.0+2" [[deps.x264_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "14cc7083fc6dff3cc44f2bc435ee96d06ed79aa7" uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a" -version = "2021.5.5+0" +version = "10164.0.1+0" [[deps.x265_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "ee567a171cce03570d77ad3a43e90218e38937a9" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "e7b67590c14d487e734dcb925924c5dc43ec85f3" uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76" -version = "3.5.0+0" +version = "4.1.0+0" [[deps.xkbcommon_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xkeyboard_config_jll"] @@ -3274,6 +3192,7 @@ version = "1.9.2+0" # ╟─93e7c7d5-a940-4764-8784-07af2f056e49 # ╟─26c74c9a-d294-11ef-2d31-67bd57d56d7c # ╟─26c75b5e-d294-11ef-173e-b3f46a1df536 +# ╟─95d47a10-f3f8-479b-afe0-21241104b758 # ╟─26c7696e-d294-11ef-25f2-dbc0946c0858 # ╠═c90176ea-918b-4643-a10f-cef277c5ea75 # ╟─cc547bfa-a130-4382-af47-73de56e4741b diff --git a/lectures/Machine Learning Overview.jl b/lectures/Machine Learning Overview.jl index 5f0802bb..9057d4ad 100644 --- a/lectures/Machine Learning Overview.jl +++ b/lectures/Machine Learning Overview.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.9 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/scientific-inquiry-loop.png?raw=true" @@ -13,13 +13,10 @@ using Markdown using InteractiveUtils # ╔═╡ a5d43e01-8f73-4c48-b565-f10eb807a9ab -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 3ceb490e-d294-11ef-1883-a50aadd2d519 -md""" -# Machine Learning Overview - -""" +title("Machine Learning Overview") # ╔═╡ d7d20de9-53c6-4e30-a1bd-874fca52f017 PlutoUI.TableOfContents() @@ -316,21 +313,19 @@ md""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" [compat] -PlutoTeachingTools = "~0.4.1" -PlutoUI = "~0.7.65" +BmlipTeachingTools = "~1.1.0" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.9" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "eedee42f1eb50eebba347d99e3995f63f96dad39" +project_hash = "e635641d8e55b0485ecb2515c1996f4b47f0454e" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -340,13 +335,21 @@ version = "1.3.2" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +version = "1.1.2" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" + +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" [[deps.ColorTypes]] deps = ["FixedPointNumbers", "Random"] @@ -368,6 +371,7 @@ version = "1.1.1+0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" [[deps.Downloads]] deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] @@ -376,6 +380,7 @@ version = "1.6.0" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" [[deps.FixedPointNumbers]] deps = ["Statistics"] @@ -409,6 +414,7 @@ version = "0.2.5" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -423,9 +429,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -447,16 +453,17 @@ version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "8.6.0+0" [[deps.LibGit2]] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" [[deps.LibGit2_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.2+0" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] @@ -465,13 +472,16 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" @@ -486,18 +496,20 @@ version = "0.5.16" [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.6+0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2023.12.12" [[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" @@ -506,7 +518,7 @@ version = "1.2.0" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.27+1" [[deps.OrderedCollections]] git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" @@ -520,21 +532,27 @@ uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" version = "2.8.3" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.11.0" + + [deps.Pkg.extensions] + REPLExt = "REPL" + + [deps.Pkg.weakdeps] + REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.PlutoTeachingTools]] deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] -git-tree-sha1 = "537c439831c0f8d37265efe850ee5c0d9c7efbe4" +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.4.1" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "3151a0c8061cc3f887019beebf359e6c4b3daa08" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.65" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -544,21 +562,19 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" [[deps.Reexport]] git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" @@ -577,24 +593,19 @@ version = "0.7.0" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[deps.Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[deps.SparseArrays]] -deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" +version = "1.11.0" [[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.11.1" + + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] -[[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] -uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" + [deps.Statistics.weakdeps] + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.TOML]] deps = ["Dates"] @@ -609,23 +620,26 @@ version = "1.10.0" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" [[deps.Tricks]] -git-tree-sha1 = "6cae795a5a9313bbb4f60683f7263318fc7d1505" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.10" +version = "0.1.12" [[deps.URIs]] -git-tree-sha1 = "cbbebadbcc76c5ca1cc4b4f3b0614b3e603b5000" +git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.5.2" +version = "1.6.1" [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" [[deps.Zlib_jll]] deps = ["Libdl"] @@ -640,7 +654,7 @@ version = "5.11.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.59.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/lectures/Probability Theory Review.jl b/lectures/Probability Theory Review.jl index 2f82f6df..57ed09fe 100644 --- a/lectures/Probability Theory Review.jl +++ b/lectures/Probability Theory Review.jl @@ -30,10 +30,7 @@ using Plots, LaTeXStrings using Distributions # ╔═╡ b305a905-06c2-4a15-8042-72ef6375720f -using PlutoUI, PlutoTeachingTools - -# ╔═╡ 7910a84c-18b3-4081-9f01-e59258a01adb -using HypertextLiteral +using BmlipTeachingTools # ╔═╡ 42b47af6-b850-4987-a2d7-805a2cb64e43 # The Disease Diagnosis example uses a combination of: @@ -46,10 +43,7 @@ using MarkdownLiteral: @mdx using Printf # ╔═╡ 3e17df5e-d294-11ef-38c7-f573724871d8 -md""" -# Probability Theory Review - -""" +title("Probability Theory Review") # ╔═╡ bcb4be20-0439-4809-a166-8c50b6b9206b PlutoUI.TableOfContents() @@ -116,7 +110,7 @@ In this lesson we introduce *Probability Theory* (PT) again. As we will see in t # ╔═╡ 3e185ab0-d294-11ef-3f7d-9bd465518274 md""" -$(section_outline("Challenge:", "Disease Diagnosis")) +$(challenge_statement("Disease Diagnosis")) ##### Problem - Given is a disease with a prevalence of 1% and a test procedure with sensitivity ('true positive' rate) of 95%, and specificity ('true negative' rate) of 85%. What is the chance that somebody who tests positive actually has the disease? @@ -528,7 +522,7 @@ This rule is called the [law of total probability](https://en.wikipedia.org/wiki """ # ╔═╡ 5377c5a4-77c4-4fa7-9f84-0c511e3bf708 -details("Click for proof", +hide_proof( md""" ```math \begin{align*} @@ -742,7 +736,7 @@ md""" # ╔═╡ 3e1ca4a8-d294-11ef-1a4f-a3443b74fe63 md""" -$(section_outline("Code Example:", "Sampling Distribution and Likelihood Function for the Coin Toss")) +$(code_example("Sampling Distribution and Likelihood Function for the Coin Toss")) Consider the following simple model for the outcome ``y \in \{0,1\}`` (tail = ``0``, head = ``1``) of a biased coin toss with a real parameter ``\theta \in [0,1]``: @@ -813,7 +807,7 @@ $(section_outline("Inference Exercise:", "Which color has the ball?")) """ # ╔═╡ 4c639e65-e06b-4c5e-b6e7-aabed6b6c0b4 -details("Click for solution", +hide_solution( md""" There are two hypotheses: let ``H = 0`` mean that the original ball in the bag was white and ``H = 1`` that it was black. Assume the prior probabilities are equal, i.e., ```math @@ -860,7 +854,7 @@ $(section_outline("Inference Exercise:", "Causality?")) """ # ╔═╡ 727dc817-0284-4c0f-9a92-21dcbea50807 -details("Click for solution", +hide_solution( md""" (a) ``p(S_1=R) = \frac{N_\text{red}}{N_\text{red}+N_\text{green}} = \frac{5}{12}`` @@ -887,7 +881,7 @@ keyconcept("", md"Probabilities describe beliefs (a ''state of knowledge''), rat # ╔═╡ 3e1d6d00-d294-11ef-1081-e11b8397eb91 ## Revisiting the Challenge: Disease Diagnosis md""" -$(section_outline("Revisiting the Challenge:", "Disease Diagnosis"; big=true, header_level=2)) +$(challenge_solution("Disease Diagnosis"; big=true)) ##### Problem @@ -938,7 +932,7 @@ The **covariance** matrix between *vectors* ``x`` and ``y`` is a mixed central m Clearly, if ``x`` and ``y`` are independent, then ``\Sigma_{xy} = 0``, since in that case ``\mathbb{E}[x y^T] = \mathbb{E}[x] \mathbb{E}[y^T] = \mu_x \mu_y^T``. -Home exercise: Proof that ``\Sigma_{xy} = \Sigma_{yx}^{T}`` (making use of ``(AB)^T = B^TA^T``). +Home exercise: Prove that ``\Sigma_{xy} = \Sigma_{yx}^{T}`` (making use of ``(AB)^T = B^TA^T``). """ @@ -965,7 +959,7 @@ No matter the specification of ``p(X)``, the mean and covariance matrix for ``Z` """ # ╔═╡ d2202628-e4f9-4289-b48e-23b5a0073f94 -details("Click for proof", +hide_proof( md""" Let ``\mathbb{E}[\cdot]`` refer to the expectation (mean) operator. By linearity of expectation and the fact that ``A`` and ``b`` are constants, ```math @@ -985,7 +979,7 @@ For the covariance matrix, ) # ╔═╡ 58f70d3e-4b64-414e-b560-327be2a0c4c2 -section_outline("Exercise:", "The PDF for the Sum of Two Variables") +exercise_statement("The PDF for the Sum of Two Variables") # ╔═╡ 3e1ea442-d294-11ef-1364-8dd9986325f7 md""" @@ -1002,7 +996,7 @@ where ``\Sigma_{yx} = \Sigma_{xy}^T``. """ # ╔═╡ 6d07be25-53d0-46b9-b197-a3680d830952 -details("Click for solution", +hide_solution( md""" Define ``A = \begin{pmatrix} I & I \end{pmatrix}`` and ``w = \begin{pmatrix} x \\ y \end{pmatrix}``, where ``I`` is the identity matrix. Then ```math @@ -1083,7 +1077,7 @@ NotebookCard("https://bmlip.github.io/course/minis/Distributions%20in%20Julia.ht # ╔═╡ 3e1f225a-d294-11ef-04c6-f3ca018ab286 md""" -$(section_outline("Code Example:", "Sum of Two Gaussian-distributed Variables"; big=true, header_level=2)) +$(code_example("Sum of Two Gaussian-distributed Variables"; big=true, header_level=2)) Consider two independent Gaussian-distributed variables ``X`` and ``Y`` (see [wikipedia normal distribution](https://en.wikipedia.org/wiki/Normal_distribution) for definition of a Gaussian (=Normal) distribution): @@ -1193,7 +1187,7 @@ P_y(y) = P_x(g(y))\,. """ # ╔═╡ 3e1f8e48-d294-11ef-0f8a-b58294a8543d -details("Click for proof", +hide_proof( md""" ```math P_y(\hat{y}) = P(y=\hat{y}) = P(h(x)=\hat{y}) = P(x=g(\hat{y})) = P_x(g(\hat{y})) \,. @@ -1213,7 +1207,7 @@ which is also known as the [Change-of-Variable theorem](https://en.wikipedia.org """ # ╔═╡ 50bdc2fe-f48d-4c4e-8b4e-170782681366 -details("Click for proof", +hide_proof( md""" We assume again that ``y = h(x)`` is a one-to-one function with ``x = g(y) = h^{-1}(y)``. Let ``a=g(c)`` and ``b=g(d)``. Then @@ -1241,7 +1235,7 @@ If the transformation ``y=h(x)`` is not invertible, then ``x=g(y)`` does not exi # ╔═╡ 3e1fb370-d294-11ef-1fb6-63a41a024691 md""" -$(section_outline("Exercise:", "Transformation of a Gaussian Variable"; big=true, header_level=2)) +$(exercise_statement("Transformation of a Gaussian Variable"; big=true, header_level=2)) ##### Problem @@ -1251,7 +1245,7 @@ Evaluate ``p_y(y)`` as a Gaussian distribution. """ # ╔═╡ 317707a3-9ef1-4c67-b451-6adcfcff50f0 -details("Click for solution", +hide_solution( md""" Note that ``h(x)`` is invertible with ``x = g(y) = \sigma y + \mu``. The change-of-variable formula leads to @@ -1343,7 +1337,7 @@ hint( ) # ╔═╡ 3b1b0869-b815-4697-9dba-3c4b4cb5ac47 -details("Click for solution", +hide_solution( md""" ```math \begin{align} @@ -1373,7 +1367,7 @@ Box 1 contains 8 apples and 4 oranges. Box 2 contains 10 apples and 2 oranges. B """ # ╔═╡ 5613e9b7-ff0d-435a-9de6-aaf293ebf592 -details("Click for solution", +hide_solution( md""" The following probabilities are given in the problem statement, ```math @@ -1401,7 +1395,7 @@ Is a speech signal a "probabilistic" (random) or a deterministic signal? """ # ╔═╡ 66ebe33c-8360-4938-9b51-625e5bed176c -details("Click for solution", +hide_solution( md""" That depends. The term “probabilistic” refers to a state-of-knowledge (or beliefs) about something—in this case, about the values of a speech signal. The key point is that the signal itself is neither inherently probabilistic nor deterministic; these labels describe our knowledge about it. @@ -1418,7 +1412,7 @@ md""" """ # ╔═╡ 91dd40f0-c373-48b3-b83b-6e8df2c43e5a -details("Click for solution", +hide_solution( md""" We use variables ``S_1 \in \{\text{t},\text{f}\}`` and ``S_2 \in \{\text{y},\text{n}\}`` for statements 1 and 2 and shorthand "y", "n", "t" and "f" for "yes", "no", "true" and "false", respectively. The problem statement provides us with the following probabilities, ```math @@ -1448,7 +1442,7 @@ When considering the distribution ``p(D|\theta)``, is it more correct to speak a """ # ╔═╡ d3b003c6-70ca-419f-a343-e35b266323f3 -details("Click for solution", +hide_solution( md""" Yes, it’s more correct to speak about the likelihood of the model parameters, not of the observed data set. Once ``D`` has been observed, it is no longer a random variable; it’s just a fixed outcome. What varies is ``\theta``, so ``L(\theta) = p(D|\theta)`` is a function of the parameters, not of the data. @@ -1460,6 +1454,9 @@ md""" # Appendix """ +# ╔═╡ 7910a84c-18b3-4081-9f01-e59258a01adb + + # ╔═╡ 70d79732-0f55-40ba-929d-fba431318848 md""" ### Disease diagnosis implementation @@ -1498,32 +1495,28 @@ Many people have trouble distinguishing ``p(A|B)`` from ``p(B|A)`` in their head # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" MarkdownLiteral = "736d6165-7244-6769-4267-6b50796e6954" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.120" -HypertextLiteral = "~0.9.5" LaTeXStrings = "~1.4.0" MarkdownLiteral = "~0.1.2" Plots = "~1.40.17" -PlutoTeachingTools = "~0.4.2" -PlutoUI = "~0.7.68" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.10" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "730c60ed3a34c5089061ded268516e181c3580ce" +project_hash = "7b4461a6af820173caf56df9fa1f688e38ce8abb" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -1539,19 +1532,27 @@ version = "1.1.3" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +version = "1.1.2" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" [[deps.BitFlags]] git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1581,13 +1582,11 @@ deps = ["FixedPointNumbers", "Random"] git-tree-sha1 = "67e11ee83a43eb71ddc950302c53bf33f0690dfe" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" version = "0.12.1" +weakdeps = ["StyledStrings"] [deps.ColorTypes.extensions] StyledStringsExt = "StyledStrings" - [deps.ColorTypes.weakdeps] - StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b" - [[deps.ColorVectorSpace]] deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"] git-tree-sha1 = "8b3b6f87ce8f65a2b4f857528fd8d70086cd72b1" @@ -1640,6 +1639,7 @@ version = "0.19.0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" [[deps.Dbus_jll]] deps = ["Artifacts", "Expat_jll", "JLLWrappers", "Libdl"] @@ -1711,6 +1711,7 @@ version = "7.1.1+0" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" [[deps.FillArrays]] deps = ["LinearAlgebra"] @@ -1833,6 +1834,7 @@ version = "0.2.5" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" [[deps.IrrationalConstants]] git-tree-sha1 = "e2222959fbc6c19554dc15174c81bf7bf3aa691c" @@ -1894,9 +1896,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -1918,16 +1920,17 @@ version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "8.6.0+0" [[deps.LibGit2]] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" [[deps.LibGit2_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.2+0" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] @@ -1936,6 +1939,7 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" [[deps.Libffi_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -1976,6 +1980,7 @@ version = "2.41.0+0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" [[deps.LogExpFunctions]] deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] @@ -1995,6 +2000,7 @@ version = "0.3.29" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" [[deps.LoggingExtras]] deps = ["Dates", "Logging"] @@ -2015,6 +2021,7 @@ version = "0.5.16" [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" [[deps.MarkdownLiteral]] deps = ["CommonMark", "HypertextLiteral"] @@ -2031,7 +2038,7 @@ version = "1.1.9" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.6+0" [[deps.Measures]] git-tree-sha1 = "c13304c81eec1ed3af7fc20e75fb6b26092a1102" @@ -2046,10 +2053,11 @@ version = "1.2.0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2023.12.12" [[deps.NaNMath]] deps = ["OpenLibm_jll"] @@ -2070,7 +2078,7 @@ version = "1.3.6+0" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] @@ -2136,9 +2144,13 @@ uuid = "30392449-352a-5448-841d-b1acce4e97dc" version = "0.44.2+0" [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.11.0" +weakdeps = ["REPL"] + + [deps.Pkg.extensions] + REPLExt = "REPL" [[deps.PlotThemes]] deps = ["PlotUtils", "Statistics"] @@ -2174,15 +2186,15 @@ version = "1.40.18" [[deps.PlutoTeachingTools]] deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] -git-tree-sha1 = "d0f6e09433d14161a24607268d89be104e743523" +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.4.4" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -2199,6 +2211,7 @@ version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" [[deps.PtrArrays]] git-tree-sha1 = "1d36ef11a9aaf1e8b74dacc6a731dd1de8fd493d" @@ -2242,12 +2255,14 @@ version = "2.11.2" Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" [[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" [[deps.RecipesBase]] deps = ["PrecompileTools"] @@ -2302,6 +2317,7 @@ version = "1.3.0" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "1.11.0" [[deps.Showoff]] deps = ["Dates", "Grisu"] @@ -2316,6 +2332,7 @@ version = "1.2.0" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] @@ -2326,7 +2343,7 @@ version = "1.2.2" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" +version = "1.11.0" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] @@ -2347,9 +2364,14 @@ uuid = "860ef19b-820b-49d6-a774-d7a799459cd3" version = "1.0.3" [[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.11.1" +weakdeps = ["SparseArrays"] + + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -2377,6 +2399,10 @@ version = "1.5.0" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112" +[[deps.StyledStrings]] +uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" +version = "1.11.0" + [[deps.SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" @@ -2384,7 +2410,7 @@ uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" +version = "7.7.0+0" [[deps.TOML]] deps = ["Dates"] @@ -2405,6 +2431,7 @@ version = "0.1.1" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" [[deps.TranscodingStreams]] git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742" @@ -2424,9 +2451,11 @@ version = "1.6.1" [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" [[deps.UnicodeFun]] deps = ["REPL"] @@ -2704,7 +2733,7 @@ version = "1.1.7+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.59.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/lectures/Regression.jl b/lectures/Regression.jl index 4036a932..cc28eea7 100644 --- a/lectures/Regression.jl +++ b/lectures/Regression.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/fig-bishop12.png?raw=true" @@ -25,10 +25,7 @@ macro bind(def, element) end # ╔═╡ f8c69b91-4415-454e-a50d-c4a37ada89d1 -using PlutoUI, PlutoTeachingTools - -# ╔═╡ 5f00f990-1c7c-4c78-9d86-2dfc88a90a36 -using HypertextLiteral +using BmlipTeachingTools # ╔═╡ 33ca4c67-d96f-457f-bc19-171f4b4b03c6 using LinearAlgebra, Random @@ -37,10 +34,7 @@ using LinearAlgebra, Random using Plots, Distributions, LaTeXStrings # ╔═╡ 234b77a8-d294-11ef-15d5-ff54ed5bec1e -md""" -# Regression - -""" +title("Regression") # ╔═╡ 66998cd5-78d6-4b22-a9c9-886436cba4dd PlutoUI.TableOfContents() @@ -78,7 +72,7 @@ md""" # ╔═╡ 234ba8c2-d294-11ef-36f6-b1f61f65557a -section_outline("Challenge:", "Finding a Secret Function" , color= "Red" ) +challenge_statement("Finding a Secret Function" , color= "Red" ) @@ -363,8 +357,7 @@ Then we equate probability masses in both domains: keyconcept("", md"This is a satisfying result: for an ordinary linear regression task, with inputs ``x``, outputs ``y``, and weights ``w``, placing a Gaussian prior on the weights ``w`` leads to both a Gaussian posterior over the weights and a Gaussian predictive distribution for the outputs. Importantly, both distributions can be computed in closed form. ") # ╔═╡ f600c228-e048-42aa-b79a-60592b367dec -section_outline( - "Challenge Revisited:", "Finding a Secret Function" , color= "Green" ) +challenge_solution("Finding a Secret Function" , color= "Green" ) # ╔═╡ c0c57aa6-155a-49a9-9ed2-d568de1b5be2 md""" @@ -535,7 +528,7 @@ As an aside, note that the dimension of ``\Lambda`` increases with the number of """ # ╔═╡ 691429de-2966-485e-8123-cbcb20c7f218 -section_outline("Code Example:", "Least Squares vs Weighted Least Squares" , color= "Green" ) +code_example("Least Squares vs Weighted Least Squares" , color= "Green" ) # ╔═╡ 234ec962-d294-11ef-1033-7b1599057825 md""" @@ -653,7 +646,7 @@ where ``y_n`` is a scalar output, ``f(x_n)`` is an ``M``-dimensional feature vec - (b) Now derive an expression for the log-likelihood ``\log p(D|\theta)``. -- (c) Proof that the maximum likelihood estimate for the parameters is given by +- (c) Prove that the maximum likelihood estimate for the parameters is given by ```math \hat\theta_{\text{ml}} = (F^T F)^{-1}F^Ty \,. @@ -666,7 +659,7 @@ where ``y_n`` is a scalar output, ``f(x_n)`` is an ``M``-dimensional feature vec """ # ╔═╡ d8e384c8-fe26-47c3-a7d4-04ae4c592ee5 -details("Click for solution", +hide_solution( md""" - (a) Rewrite the model in matrix form by lumping input features in a matrix ``F=[f(x_1),\ldots,f(x_N)]^T``, outputs and noise in the vectors ``y=[y_1,\ldots,y_N]^T`` and ``e=[e_1,\ldots,e_N]^T``, respectively. @@ -686,7 +679,7 @@ e &\sim \mathcal{N}(0,\sigma^2 I) \end{align*} ``` -- (c) Proof that the maximum likelihood estimate for the parameters is given by +- (c) Prove that the maximum likelihood estimate for the parameters is given by ```math \hat\theta_{\text{ml}} = (F^T F)^{-1}F^Ty \,. @@ -783,6 +776,9 @@ md""" # Appendix """ +# ╔═╡ 5f00f990-1c7c-4c78-9d86-2dfc88a90a36 + + # ╔═╡ 3b2ca3c2-ada2-447f-818d-e3cc7c52facb md""" # scratchbook (to be removed in final version) @@ -832,31 +828,27 @@ And some plots of draws of posteriors for the functions ``w^T \phi(x)`` (Bishop, # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.120" -HypertextLiteral = "~0.9.5" LaTeXStrings = "~1.4.0" Plots = "~1.40.17" -PlutoTeachingTools = "~0.4.4" -PlutoUI = "~0.7.62" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "9f6ee2c716b3724f3075f719bb750364ee313c5c" +project_hash = "61c8164fc50937999e83534a3a559f7fe70b536f" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -887,6 +879,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1405,7 +1403,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -1514,9 +1512,9 @@ version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] diff --git a/lectures/The Gaussian Distribution.jl b/lectures/The Gaussian Distribution.jl index 5decfb46..6d3c7bd0 100644 --- a/lectures/The Gaussian Distribution.jl +++ b/lectures/The Gaussian Distribution.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.16 #> [frontmatter] #> image = "https://github.com/bmlip/course/blob/v2/assets/figures/fig-linear-system.png?raw=true" @@ -31,34 +31,16 @@ using HCubature, LinearAlgebra# Numerical integration package using Random # ╔═╡ c97c495c-f7fe-4552-90df-e2fb16f81d15 -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ 3ec821fd-cf6c-4603-839d-8c59bb931fa9 using Distributions, Plots, LaTeXStrings -# ╔═╡ b9abf984-d294-11ef-1eaa-3358379f8b44 -begin - using SpecialFunctions - let - X = Normal(0, 1) - Y = Normal(0, 1) - pdf_product_std_normals(z::Real) = besselk(0, abs(z))/π - - range1 = range(-4,stop=4,length=100) - plot(range1, t -> pdf(X, t); label=L"p(X)=p(Y)=\mathcal{N}(0,1)", fill=(0, 0.1)) - plot!(range1, t -> pdf(X,t)*pdf(Y,t); label=L"p(X)*p(Y)", fill=(0, 0.1)) - plot!(range1, pdf_product_std_normals; label=L"p(Z=X*Y)", fill=(0, 0.1)) - end -end - # ╔═╡ 00482666-0772-4e5d-bb35-df7b6fb67a1b -using HypertextLiteral +using SpecialFunctions # ╔═╡ b9a38e20-d294-11ef-166b-b5597125ed6d -md""" -# Continuous Data and the Gaussian Distribution - -""" +title("Continuous Data and the Gaussian Distribution") # ╔═╡ 5e9a51b1-c6e5-4fb5-9df3-9b189f3302e8 PlutoUI.TableOfContents() @@ -89,7 +71,7 @@ md""" """ # ╔═╡ 82025c2f-a21f-4080-b301-3ffe3715442d -section_outline("Challenge:", "Classify a Gaussian Sample" , color= "red" ) +challenge_statement("Classify a Gaussian Sample" , color= "red" ) # ╔═╡ b9a48c60-d294-11ef-3b90-03053fcd82fb md""" @@ -252,7 +234,7 @@ md""" A commonly occurring example of a linear transformation is the *sum of two independent Gaussian variables*: -Let ``x \sim \mathcal{N} \left(\mu_x, \sigma_x^2 \right)`` and ``y \sim \mathcal{N} \left(\mu_y, \sigma_y^2 \right)``. Proof that the PDF for ``z=x+y`` is given by +Let ``x \sim \mathcal{N} \left(\mu_x, \sigma_x^2 \right)`` and ``y \sim \mathcal{N} \left(\mu_y, \sigma_y^2 \right)``. Prove that the PDF for ``z=x+y`` is given by ```math p(z) = \mathcal{N} \left(z\,|\,\mu_x+\mu_y, \sigma_x^2 +\sigma_y^2 \right) \tag{SRG-8} @@ -262,7 +244,7 @@ p(z) = \mathcal{N} \left(z\,|\,\mu_x+\mu_y, \sigma_x^2 +\sigma_y^2 \right) \tag{ """ # ╔═╡ 36eff7bc-72f2-4b48-a109-1861af6834aa -details("Click for proof", +hide_proof( md""" First, recognize that ``z=x+y`` can be written as a linear transformation ``z=A w``, where ```math @@ -388,7 +370,7 @@ Let us derive the maximum likelihood estimates for the parameters ``\mu`` and `` md""" ##### Evaluation of log-likelihood function -Let ``\theta =\{\mu,\Sigma\}``. Proof that the log-likelihood (LLH) function ``\log p(D|\theta)`` can be worked out to +Let ``\theta =\{\mu,\Sigma\}``. Prove that the log-likelihood (LLH) function ``\log p(D|\theta)`` can be worked out to ```math \log p(D|\theta) = @@ -416,7 +398,7 @@ details("click to see proof", md""" ##### Maximum likelihood estimate of mean -Proof that the maximum likelihood estimate of the mean is given by +Prove that the maximum likelihood estimate of the mean is given by ```math \hat{\mu} = \frac{1}{N}\sum_n x_n \,. ``` @@ -675,7 +657,7 @@ NotebookCard("https://bmlip.github.io/course/minis/Distributions%20in%20Julia.ht # ╔═╡ b9a7073a-d294-11ef-2330-49ffa7faff21 md""" -$(section_outline("Code Example:", "Product of Two Gaussian PDFs")) +$(code_example("Product of Two Gaussian PDFs")) Let's plot the exact product of two Gaussian PDFs as well as the normalized product according to the above derivation. """ @@ -759,7 +741,7 @@ As an exercise, interpret the formula for the conditional mean (``\mathbb{E}[y|x # ╔═╡ b9a9565c-d294-11ef-1b67-83d1ab18035b md""" -$(section_outline("Code Example:", "Joint, Marginal, and Conditional Gaussian Distributions")) +$(code_example("Joint, Marginal, and Conditional Gaussian Distributions")) Let's plot the joint, marginal, and conditional distributions for some Gaussians. @@ -940,7 +922,7 @@ Note that uncertainty about ``x_{N+1}`` involves both uncertainty about the para """ # ╔═╡ 922f0eb6-9e29-4b6c-9701-cb7b2f07bb7a -details("Click for solution", +hide_solution( md""" ```math \begin{align*} @@ -961,7 +943,7 @@ and transition ``2`` derives from using the multiplication rule for Gaussians. """) # ╔═╡ 9bd38e28-73d4-4c6c-a1fe-35c7a0e750b3 -section_outline("Challenge Revisited:", "Classify a Gaussian Sample", header_level=2, color="red") +challenge_solution("Classify a Gaussian Sample", header_level=2, color="red") # ╔═╡ b9ac2d3c-d294-11ef-0d37-65a65525ad28 md""" @@ -1008,7 +990,7 @@ To determine the MLE of ``\mu`` as a special case of Bayesian inference, we let """ # ╔═╡ 0d303dba-51d4-4413-8001-73ed98bf74df -details("Click for proof", +hide_proof( md""" ```math \begin{align} @@ -1034,7 +1016,7 @@ md""" Having an expression for the maximum likelihood estimate, it is now possible to rewrite the (Bayesian) posterior mean for ``\mu`` as the combination of a prior-based prediction and likelihood-based (data-based) correction. -Proof that +Prove that ```math \underbrace{\mu_N}_{\substack{\text{posterior} \\ \text{mean}}}= \overbrace{\underbrace{\mu_0}_{\substack{\text{prior} \\ \text{mean}}}}^{\substack{\text{prior-based} \\ \text{prediction}}} + \overbrace{\underbrace{\frac{N \sigma_0^2}{N \sigma_0^2 + \sigma^2}}_{\text{gain}}\cdot \underbrace{\left(\mu_{\text{ML}} - \mu_0 \right)}_{\text{prediction error}}}^{\text{data-based correction}}\tag{B-2.141} @@ -1044,7 +1026,7 @@ Proof that """ # ╔═╡ d05975bb-c5cc-470a-a6f3-60bc43c51e89 -details("Click for proof", +hide_proof( md""" ```math \begin{align*} @@ -1167,7 +1149,7 @@ Recursive Bayesian estimation as discussed here is the basis for **adaptive sign # ╔═╡ b9ab2e32-d294-11ef-2ccc-9760ead59972 md""" -$(section_outline("Code Example:", "Kalman Filtering")) +$(code_example("Kalman Filtering")) Let's implement the Kalman filter described above. We'll use it to recursively estimate the value of ``\theta`` based on noisy observations. @@ -1331,7 +1313,7 @@ md""" """ # ╔═╡ f711b053-dccf-4bf1-b285-e8da94a48b68 -details("Click for solution", +hide_solution( md""" - (a) Evaluate the outgoing message ``\overrightarrow{\mu}_{Z}(z)``. @@ -1407,7 +1389,7 @@ We assume that ``\sigma`` has a known value and are interested in deriving an es """ # ╔═╡ fa197526-6706-47ce-b84b-5675eee00610 -details("Click for solution", +hide_solution( md""" - (a) Derive the Bayesian (posterior) estimate ``p(A|D)``. @@ -1487,7 +1469,7 @@ p(z) = p\left(\begin{bmatrix} x \\ \theta \end{bmatrix}\right) = \mathcal{N} \le """ # ╔═╡ 03c399e1-d0d8-493a-9f95-4209918d132a -details("Click for solution", +hide_solution( md""" Let's first compute the moments for the marginals ``p(x)`` and ``p(\theta)``: @@ -1718,7 +1700,7 @@ where ``\mathrm{K}_n(z)`` is a [modified Bessel function of the second kind](ht # ╔═╡ b9abdc7e-d294-11ef-394a-a708c96c86fc md""" -$(section_outline("Code Example:", "Product of Gaussian Distributions")) +$(code_example("Product of Gaussian Distributions")) We plot ``p(Z=XY)`` and ``p(X)p(Y)`` for ``X\sim\mathcal{N}(0,1)`` and ``Y \sim \mathcal{N}(0,1)`` to give an idea of how these distributions differ. @@ -1726,6 +1708,18 @@ We plot ``p(Z=XY)`` and ``p(X)p(Y)`` for ``X\sim\mathcal{N}(0,1)`` and ``Y \sim """ +# ╔═╡ b9abf984-d294-11ef-1eaa-3358379f8b44 +let + X = Normal(0, 1) + Y = Normal(0, 1) + pdf_product_std_normals(z::Real) = besselk(0, abs(z))/π + + range1 = range(-4,stop=4,length=100) + plot(range1, t -> pdf(X, t); label=L"p(X)=p(Y)=\mathcal{N}(0,1)", fill=(0, 0.1)) + plot!(range1, t -> pdf(X,t)*pdf(Y,t); label=L"p(X)*p(Y)", fill=(0, 0.1)) + plot!(range1, pdf_product_std_normals; label=L"p(Z=X*Y)", fill=(0, 0.1)) +end + # ╔═╡ b9ac09c4-d294-11ef-2cb8-270289d01f25 md""" In short, Gaussian-distributed variables remain Gaussian in linear systems, but this is not the case in non-linear systems. @@ -1740,25 +1734,21 @@ md""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49" -HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" [compat] +BmlipTeachingTools = "~1.1.0" Distributions = "~0.25.120" HCubature = "~1.7.0" -HypertextLiteral = "~0.9.5" LaTeXStrings = "~1.4.0" Plots = "~1.40.17" -PlutoTeachingTools = "~0.4.4" -PlutoUI = "~0.7.68" SpecialFunctions = "~2.5.1" """ @@ -1766,9 +1756,9 @@ SpecialFunctions = "~2.5.1" PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "3af7b7a1e24ddf3753ac4474e9b19716a9f90072" +project_hash = "07a127c4fa2593ca07bbc3eec98e4cf0edebbb0c" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -1799,6 +1789,12 @@ git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d" uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" version = "0.1.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" + [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" @@ -1948,9 +1944,9 @@ version = "0.1.11" [[deps.Expat_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "d55dffd9ae73ff72f1c0482454dcf2ec6c6c4a63" +git-tree-sha1 = "7bb1361afdb33c7f2b085aa49ea8fe1b0fb14e58" uuid = "2e619515-83b5-522b-bb60-26c02a35a201" -version = "2.6.5+0" +version = "2.7.1+0" [[deps.FFMPEG]] deps = ["FFMPEG_jll"] @@ -2122,9 +2118,9 @@ version = "0.21.4" [[deps.JpegTurbo_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "eac1206917768cb54957c65a615460d87b455fc1" +git-tree-sha1 = "e95866623950267c1e4878846f848d94810de475" uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" -version = "3.1.1+0" +version = "3.1.2+0" [[deps.LAME_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -2338,7 +2334,7 @@ version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+4" +version = "0.8.5+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -2447,9 +2443,9 @@ version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "2d7662f95eafd3b6c346acdbfc11a762a2256375" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.69" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] diff --git a/lectures/The Multinomial Distribution.jl b/lectures/The Multinomial Distribution.jl index fde66437..05dcf784 100644 --- a/lectures/The Multinomial Distribution.jl +++ b/lectures/The Multinomial Distribution.jl @@ -1,5 +1,5 @@ ### A Pluto.jl notebook ### -# v0.20.13 +# v0.20.15 #> [frontmatter] #> description = "Bayesian and maximum likelihood density estimation for discretely valued data sets." @@ -12,13 +12,10 @@ using Markdown using InteractiveUtils # ╔═╡ d3a4a1dc-3fdf-479d-a51c-a1e23073c556 -using PlutoUI, PlutoTeachingTools +using BmlipTeachingTools # ╔═╡ d8422bf2-d294-11ef-0144-098f414c6454 -md""" -# Discrete Data and the Multinomial Distribution - -""" +title("Discrete Data and the Multinomial Distribution") # ╔═╡ 1c6d16be-e8e8-45f1-aa32-c3fb08af19ce PlutoUI.TableOfContents() @@ -283,7 +280,7 @@ Proof for yourself that """ # ╔═╡ 4482e857-af6b-4459-a0a2-cd7ad57ed94f -details("Click for proof", +hide_proof( md""" ```math \begin{align*} @@ -407,7 +404,7 @@ with probabilities ``p(x_{nk} = 1)=\mu_k``. """ # ╔═╡ 01c4c590-fece-49a5-8979-6e0d54f7850a -details("Click for solution", +hide_solution( md""" Derivations are in the lecture notes. @@ -449,7 +446,7 @@ Show that """ # ╔═╡ 448d0679-b47a-4db9-ad7d-a45786350fef -details("Click for solution", +hide_solution( md""" - (a) The probability mass function of a **multinomial distribution** is @@ -487,7 +484,7 @@ Show that Laplace's generalized rule of succession can be worked out to a predic """ # ╔═╡ 3c2ee96d-18a6-45d0-a2cf-f2ebbf5e22f0 -details("Click for solution", +hide_solution( md""" ```math @@ -516,21 +513,19 @@ md""" # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] -PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69" -PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" +BmlipTeachingTools = "656a7065-6f73-6c65-7465-6e646e617262" [compat] -PlutoTeachingTools = "~0.3.1" -PlutoUI = "~0.7.62" +BmlipTeachingTools = "~1.1.0" """ # ╔═╡ 00000000-0000-0000-0000-000000000002 PLUTO_MANIFEST_TOML_CONTENTS = """ # This file is machine-generated - editing it directly is not advised -julia_version = "1.11.4" +julia_version = "1.11.6" manifest_format = "2.0" -project_hash = "65874a65b39702642b8f819a8904f6c2925e64f2" +project_hash = "e635641d8e55b0485ecb2515c1996f4b47f0454e" [[deps.AbstractPlutoDingetjes]] deps = ["Pkg"] @@ -550,26 +545,23 @@ version = "1.11.0" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" version = "1.11.0" -[[deps.CodeTracking]] -deps = ["InteractiveUtils", "UUIDs"] -git-tree-sha1 = "062c5e1a5bf6ada13db96a4ae4749a4c2234f521" -uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" -version = "1.3.9" +[[deps.BmlipTeachingTools]] +deps = ["HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoTeachingTools", "PlutoUI", "Reexport"] +git-tree-sha1 = "17747c9318a7e81cd8ca4ee3d414d96e7d8bba3e" +uuid = "656a7065-6f73-6c65-7465-6e646e617262" +version = "1.1.0" [[deps.ColorTypes]] deps = ["FixedPointNumbers", "Random"] git-tree-sha1 = "67e11ee83a43eb71ddc950302c53bf33f0690dfe" uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" version = "0.12.1" -weakdeps = ["StyledStrings"] [deps.ColorTypes.extensions] StyledStringsExt = "StyledStrings" -[[deps.Compiler]] -git-tree-sha1 = "382d79bfe72a406294faca39ef0c3cef6e6ce1f1" -uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" -version = "0.1.1" + [deps.ColorTypes.weakdeps] + StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -630,12 +622,6 @@ git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.4" -[[deps.JuliaInterpreter]] -deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"] -git-tree-sha1 = "6ac9e4acc417a5b534ace12690bc6973c25b862f" -uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" -version = "0.10.3" - [[deps.LaTeXStrings]] git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c" uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" @@ -643,9 +629,9 @@ version = "1.4.0" [[deps.Latexify]] deps = ["Format", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "OrderedCollections", "Requires"] -git-tree-sha1 = "4f34eaabe49ecb3fb0d58d6015e32fd31a733199" +git-tree-sha1 = "52e1296ebbde0db845b356abbbe67fb82a0a116c" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" -version = "0.16.8" +version = "0.16.9" [deps.Latexify.extensions] DataFramesExt = "DataFrames" @@ -697,12 +683,6 @@ version = "1.11.0" uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" version = "1.11.0" -[[deps.LoweredCodeUtils]] -deps = ["Compiler", "JuliaInterpreter"] -git-tree-sha1 = "b882a7dd7ef37643066ae8f9380beea8fdd89cae" -uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" -version = "3.4.2" - [[deps.MIMEs]] git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691" uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65" @@ -755,34 +735,24 @@ version = "2.8.3" deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" version = "1.11.0" -weakdeps = ["REPL"] [deps.Pkg.extensions] REPLExt = "REPL" -[[deps.PlutoHooks]] -deps = ["InteractiveUtils", "Markdown", "UUIDs"] -git-tree-sha1 = "072cdf20c9b0507fdd977d7d246d90030609674b" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0774" -version = "0.0.5" - -[[deps.PlutoLinks]] -deps = ["FileWatching", "InteractiveUtils", "Markdown", "PlutoHooks", "Revise", "UUIDs"] -git-tree-sha1 = "8f5fa7056e6dcfb23ac5211de38e6c03f6367794" -uuid = "0ff47ea0-7a50-410d-8455-4348d5de0420" -version = "0.1.6" + [deps.Pkg.weakdeps] + REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.PlutoTeachingTools]] -deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoLinks", "PlutoUI"] -git-tree-sha1 = "8252b5de1f81dc103eb0293523ddf917695adea1" +deps = ["Downloads", "HypertextLiteral", "Latexify", "Markdown", "PlutoUI"] +git-tree-sha1 = "85778cdf2bed372008e6646c64340460764a5b85" uuid = "661c6b06-c737-4d37-b85c-46df65de6f69" -version = "0.3.1" +version = "0.4.5" [[deps.PlutoUI]] deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Downloads", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"] -git-tree-sha1 = "ec9e63bd098c50e4ad28e7cb95ca7a4860603298" +git-tree-sha1 = "fcfec547342405c7a8529ea896f98c0ffcc4931d" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" -version = "0.7.68" +version = "0.7.70" [[deps.PrecompileTools]] deps = ["Preferences"] @@ -792,20 +762,15 @@ version = "1.2.1" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6" +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.4.3" +version = "1.5.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" version = "1.11.0" -[[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" -version = "1.11.0" - [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -822,18 +787,6 @@ git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" uuid = "ae029012-a4dd-5104-9daa-d747884805df" version = "1.3.1" -[[deps.Revise]] -deps = ["CodeTracking", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "REPL", "Requires", "UUIDs", "Unicode"] -git-tree-sha1 = "f6f7d30fb0d61c64d0cfe56cf085a7c9e7d5bc80" -uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" -version = "3.8.0" - - [deps.Revise.extensions] - DistributedExt = "Distributed" - - [deps.Revise.weakdeps] - Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" - [[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" version = "0.7.0" @@ -842,10 +795,6 @@ version = "0.7.0" uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" version = "1.11.0" -[[deps.Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" -version = "1.11.0" - [[deps.Statistics]] deps = ["LinearAlgebra"] git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" @@ -858,10 +807,6 @@ version = "1.11.1" [deps.Statistics.weakdeps] SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -[[deps.StyledStrings]] -uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" -version = "1.11.0" - [[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" @@ -878,9 +823,9 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" version = "1.11.0" [[deps.Tricks]] -git-tree-sha1 = "6cae795a5a9313bbb4f60683f7263318fc7d1505" +git-tree-sha1 = "372b90fe551c019541fafc6ff034199dc19c8436" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" -version = "0.1.10" +version = "0.1.12" [[deps.URIs]] git-tree-sha1 = "bef26fb046d031353ef97a82e3fdb6afe7f21b1a" diff --git a/tools/update_notebook_packages.jl b/tools/update_notebook_packages.jl index 2799b0e9..a5878cd6 100644 --- a/tools/update_notebook_packages.jl +++ b/tools/update_notebook_packages.jl @@ -1,4 +1,4 @@ -if !isdir("pluto-deployment-environment") || length(ARGS) != 1 +if !isdir("pluto-slider-server-environment") || length(ARGS) != 1 error(""" Run me from the root of the repository directory, using: @@ -13,7 +13,7 @@ if !(v"1.11.0-aaa" < VERSION < v"1.12.0") end import Pkg -Pkg.activate("./pluto-deployment-environment") +Pkg.activate("./pluto-slider-server-environment") Pkg.instantiate() import Pluto @@ -21,11 +21,13 @@ import Pluto flatmap(args...) = vcat(map(args...)...) -all_files_recursive = flatmap(walkdir("src")) do (root, _dirs, files) +getfrom(dir) = flatmap(walkdir("lectures")) do (root, _dirs, files) joinpath.((root,), files) end -all_notebooks = filter(Pluto.is_pluto_notebook, all_files_recursive) +all_files_recursive = [getfrom("lectures")..., getfrom("minis")...] + +all_notebooks = filter!(Pluto.is_pluto_notebook, all_files_recursive) level = getfield(Pkg, Symbol("UPLEVEL_$(ARGS[1])"))