TuringModels

Globe tossing

Data

import Random

Random.seed!(1)

n = 9
k = 6;

Model

using Turing

@model function globe_toss(n, k)
    θ ~ Beta(1, 1)
    k ~ Binomial(n, θ)
    return k, θ
end;

Output

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     = 3.28 seconds
Compute duration  = 3.28 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.6460    0.1406     0.0044    0.0050   465.4598    0.9995      141.8220

Quantiles
  parameters      2.5%     25.0%     50.0%     75.0%     97.5%
      Symbol   Float64   Float64   Float64   Float64   Float64

           θ    0.3308    0.5578    0.6581    0.7485    0.8880

using StatsPlots

StatsPlots.plot(chns)