This notebook lets you test out your installation of Jupyter and Julia. It will also automatically download all the packages you need for the course, precompile them and check if they run correctly.
# Check correct Julia version (will throw error if false)
@assert VERSION == v"1.6.3"
# Set up workspace (downloads and installs necessary packages)
using Pkg
Pkg.activate("./workspace/")
Pkg.instantiate();
Activating environment at `~/syndr/Wouter/Onderwijs/Vakken/tueindhoven/5SSD0 - Bayesian Machine Learning & Information Processing/2021-2022 Q2/BMLIP/lessons/notebooks/probprog/workspace/Project.toml` Installed x264_jll ──────────── v2021.5.5+0 Installed libfdk_aac_jll ────── v2.0.2+0 Installed x265_jll ──────────── v3.5.0+0 Installed PyPlot ────────────── v2.10.0 Installed DocStringExtensions ─ v0.8.6 Installed Plots ─────────────── v1.23.6 Installed Distributions ─────── v0.25.28 Installed Bzip2_jll ─────────── v1.0.8+0 Installed HDF5 ──────────────── v0.15.7 Installed PlotUtils ─────────── v1.0.15 Installed DiffRules ─────────── v1.4.0 Installed ForwardDiff ───────── v0.10.23 Installed MacroTools ────────── v0.5.9 Installed StatsBase ─────────── v0.33.12 Installed PDMats ────────────── v0.11.3 Installed PyCall ────────────── v1.92.5 Installed PrettyTables ──────── v1.2.3 Installed IrrationalConstants ─ v0.1.1 Installed DataAPI ───────────── v1.9.0 Installed ChangesOfVariables ── v0.1.1 Installed QuadGK ────────────── v2.4.2 Installed Latexify ──────────── v0.15.9 Installed StaticArrays ──────── v1.2.13 Installed DensityInterface ──── v0.3.3 Installed DataFrames ────────── v1.2.2 Installed Missings ──────────── v1.0.2 Installed RecipesBase ───────── v1.1.2 Installed FileIO ────────────── v1.11.2 Installed EarCut_jll ────────── v2.2.3+0 Installed UnicodeFun ────────── v0.4.1 Installed InvertedIndices ───── v1.1.0 Installed Fontconfig_jll ────── v2.13.93+0 Installed StatsFuns ─────────── v0.9.13 Installed LogExpFunctions ───── v0.3.5 Installed Reexport ──────────── v1.2.2 Installed StructArrays ──────── v0.6.3 Installed Blosc ─────────────── v0.7.1 Installed SentinelArrays ────── v1.3.8 Installed GR_jll ────────────── v0.62.0+0 Installed FreeType2_jll ─────── v2.10.4+0 Installed Tables ────────────── v1.6.0 Installed PooledArrays ──────── v1.3.0 Installed InverseFunctions ──── v0.1.2 Installed LaTeXStrings ──────── v1.3.0 Installed RecipesPipeline ───── v0.4.1 Installed SpecialFunctions ──── v1.8.1 Installed GeometryBasics ────── v0.4.1 Installed ChainRulesCore ────── v1.11.1 Installed FFMPEG_jll ────────── v4.4.0+0 Installed FillArrays ────────── v0.12.7 Installed HTTP ──────────────── v0.9.16 Installed VersionParsing ────── v1.2.1 Installed Parsers ───────────── v1.1.2 Installed Cairo_jll ─────────── v1.16.1+0 Installed Compat ────────────── v3.40.0 Installed ForneyLab ─────────── v0.11.3 Installed libass_jll ────────── v0.15.1+0 Installed GR ────────────────── v0.62.1 Installed ColorSchemes ──────── v3.15.0 Building HDF5 ──→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/698c099c6613d7b7f151832868728f426abe698b/build.log` Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/4ba3651d33ef76e24fef6a598b63ffd1c5e1cd17/build.log` Building GR ────→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/30f2b340c2fff8410d89bfcdc9c0a6dd661ac5f7/build.log` Precompiling project... ✓ OpenLibm_jll ✓ DataAPI ✓ Reexport ✓ LaTeXStrings ✓ InvertedIndices ✓ PDMats ✓ RecipesBase ✓ IrrationalConstants ✓ UnicodeFun ✓ InverseFunctions ✓ Compat ✓ ChangesOfVariables ✓ FillArrays ✓ SentinelArrays ✓ DocStringExtensions ✓ libfdk_aac_jll ✓ Blosc ✓ Graphite2_jll ✓ Missings ✓ x265_jll ✓ PooledArrays ✓ Bzip2_jll ✓ x264_jll ✓ EarCut_jll ✓ Tables ✓ MacroTools ✓ DensityInterface ✓ FileIO ✓ FreeType2_jll ✓ CommonSubexpressions ✓ ChainRulesCore ✓ HTTP ✓ Latexify ✓ Fontconfig_jll ✓ HDF5 ✓ DataStructures ✓ Cairo_jll ✓ SortingAlgorithms ✓ Documenter ✓ Qt5Base_jll ✓ LogExpFunctions ✓ QuadGK ✓ HarfBuzz_jll ✓ JLD ✓ Colors ✓ libass_jll ✓ StaticArrays ✓ StatsBase ✓ PyCall ✓ FFMPEG_jll ✓ PrettyTables ✓ DiffResults ✓ Contour ✓ FFMPEG ✓ GR_jll ✓ StructArrays ✓ CSV ✓ SpecialFunctions ✓ DiffRules ✓ GR ✓ PyPlot ✓ ColorSchemes ✓ StatsFuns ✓ ForwardDiff ✓ GeometryBasics ✓ Distributions ✓ PlotUtils ✓ ForneyLab ✓ RecipesPipeline ✓ PlotThemes ✓ DataFrames ✓ Plots 72 dependencies successfully precompiled in 71 seconds (89 already precompiled)
# Test ForneyLab (will throw errors if inference failed)
using ForneyLab
graph = FactorGraph()
@RV μ ~ GaussianMeanVariance(0.0, 1.0)
@RV x ~ GaussianMeanVariance(μ, 1.0)
placeholder(x, :x)
algorithm = messagePassingAlgorithm(μ, id=:μ)
source_code = algorithmSourceCode(algorithm)
eval(Meta.parse(source_code))
data = Dict(:x => 3.0)
marginals = Dict()
stepμ!(data, marginals)
@assert typeof(marginals) == Dict{Any,Any}
@assert marginals[:μ] == ProbabilityDistribution(Univariate,GaussianWeightedMeanPrecision, xi=3.0, w=2.0)
┌ Info: Precompiling ForneyLab [9fc3f58a-c2cc-5bff-9419-6a294fefdca9] └ @ Base loading.jl:1342
# Test plotting
using Plots
pyplot()
x = range(0, stop=10, length=50)
y = x.^3
plot(x, y, label="", xlabel="x", ylabel="y")
┌ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] └ @ Base loading.jl:1342 ┌ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] └ @ Base loading.jl:1342
# Test Unicode characters in plots and LaTeXString
using LaTeXStrings
θ = range(0, stop=1, length=50)
pθ = θ.^3 .* (1 .- θ).^7
plot(θ, pθ, xlabel="θ", ylabel="p(θ)", label=L"p(θ) = \prod_{i=1}^{N} θ^{X_i} \cdot (1-\theta)^{1 - X_i}")
# Testing data loading and management
using CSV
using DataFrames
df = DataFrame(CSV.File("../datasets/old_faithful.csv"))
271 rows × 2 columns
3.600000 | 79.000000 | |
---|---|---|
Float64 | Float64 | |
1 | 1.8 | 54.0 |
2 | 3.333 | 74.0 |
3 | 2.283 | 62.0 |
4 | 4.533 | 85.0 |
5 | 2.883 | 55.0 |
6 | 4.7 | 88.0 |
7 | 3.6 | 85.0 |
8 | 1.95 | 51.0 |
9 | 4.35 | 85.0 |
10 | 1.833 | 54.0 |
11 | 3.917 | 84.0 |
12 | 4.2 | 78.0 |
13 | 1.75 | 47.0 |
14 | 4.7 | 83.0 |
15 | 2.167 | 52.0 |
16 | 1.75 | 62.0 |
17 | 4.8 | 84.0 |
18 | 1.6 | 52.0 |
19 | 4.25 | 79.0 |
20 | 1.8 | 51.0 |
21 | 1.75 | 47.0 |
22 | 3.45 | 78.0 |
23 | 3.067 | 69.0 |
24 | 4.533 | 74.0 |
25 | 3.6 | 83.0 |
26 | 1.967 | 55.0 |
27 | 4.083 | 76.0 |
28 | 3.85 | 78.0 |
29 | 4.433 | 79.0 |
30 | 4.3 | 73.0 |
⋮ | ⋮ | ⋮ |