using Reactive, Interact, PyPlot p(y,θ) = θ.^y .* (1 .- θ).^(1 .- y) f = figure() @manipulate for y=false, θ=0:0.1:1; withfig(f) do # Plot the sampling distribution subplot(221); stem([0,1], p([0,1],θ)); title("Sampling distribution"); xlim([-0.5,1.5]); ylim([0,1]); xlabel("y"); ylabel("p(y|θ=$(θ))"); # Plot the likelihood function _θ = range(0.0, stop=1.0, length=100) subplot(222); plot(_θ, p(convert(Float64,y), _θ)); title("Likelihood function"); xlabel("θ"); ylabel("L(θ) = p(y=$(convert(Float64,y))|θ)"); end end using Reactive, Interact, PyPlot, Distributions f = figure() @manipulate for μx=0:0.1:4, σx=0.1:0.1:1.9,μy=0:0.1:4, σy=0.1:0.1:0.9; withfig(f) do μz = μx+μy; σz = sqrt(σx^2 + σy^2) x = Normal(μx, σx) y = Normal(μy, σy) z = Normal(μz, σz) range_min = minimum([μx-2*σx, μy-2*σy, μz-2*σz]) range_max = maximum([μx+2*σx, μy+2*σy, μz+2*σz]) range_grid = range(range_min, stop=range_max, length=100) plot(range_grid, pdf.(x,range_grid), "k-") plot(range_grid, pdf.(y,range_grid), "b-") plot(range_grid, pdf.(z,range_grid), "r-") legend([L"p_X", L"p_Y", L"p_Z"]) grid() end end open("../../styles/aipstyle.html") do f display("text/html", read(f,String)) end