import Random
Random.seed!(1)
n = 9
k = 6;
using Turing
@model function globe_toss(n, k)
θ ~ Beta(1, 1)
k ~ Binomial(n, θ)
return k, θ
end;
using Random
Random.seed!(1)
chns = sample(globe_toss(n, k), NUTS(), 1000)
Chains MCMC chain (1000×13×1 Array{Float64, 3}):
Iterations = 501:1:1500
Number of chains = 1
Samples per chain = 1000
Wall duration = 4.11 seconds
Compute duration = 4.11 seconds
parameters = θ
internals = lp, n_steps, is_accept, acceptance_rate, log_density, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size
Summary Statistics
parameters mean std naive_se mcse ess rhat ess_per_sec
Symbol Float64 Float64 Float64 Float64 Float64 Float64 Float64
θ 0.6421 0.1370 0.0043 0.0040 864.3717 0.9991 210.5143
Quantiles
parameters 2.5% 25.0% 50.0% 75.0% 97.5%
Symbol Float64 Float64 Float64 Float64 Float64
θ 0.3574 0.5520 0.6464 0.7433 0.8832
using StatsPlots
StatsPlots.plot(chns)
"/home/runner/work/TuringModels.jl/TuringModels.jl/__site/assets/models/globe-tossing/code/output/chns.svg"