# Probabilistic Programming 0: Check installation¶

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.

In [1]:
# Check correct Julia version (will throw error if false)
@assert VERSION == v"1.5.2"
In [2]:
using Pkg
Pkg.activate("./workspace/")
Pkg.instantiate();
Activating environment at ~/biaslab/repos/BMLIP/lessons/notebooks/probprog/workspace/Project.toml
In [3]:
# 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)
In [4]:
# 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]
Out[4]:
In [5]:
# Test Unicode characters in plots and LaTeXString
using LaTeXStrings

θ = range(0, stop=1, length=50)
= θ.^3 .* (1 .- θ).^7

plot(θ, , xlabel="θ", ylabel="p(θ)", label=L"p(θ) = \prod_{i=1}^{N} θ^{X_i} \cdot (1-\theta)^{1 - X_i}")
Out[5]:
In [6]:
using CSV
using DataFrames

Out[6]:

271 rows × 2 columns

3.60000079.000000
Float64Float64
11.854.0
23.33374.0
32.28362.0
44.53385.0
52.88355.0
64.788.0
73.685.0
81.9551.0
94.3585.0
101.83354.0
113.91784.0
124.278.0
131.7547.0
144.783.0
152.16752.0
161.7562.0
174.884.0
181.652.0
194.2579.0
201.851.0
211.7547.0
223.4578.0
233.06769.0
244.53374.0
253.683.0
261.96755.0
274.08376.0
283.8578.0
294.43379.0
304.373.0