In [1]:
using Stochy, Gadfly, Stochy.GadflySupport
In [6]:
posterior = @pp pmcmc(100,100) do
    local
    colors = [:black, :blue, :green, :orange, :red],
    prototype = 5 * ~Dir(5, 1.0),
    bag1 = ~Dir(prototype),
    bag2 = ~Dir(prototype),
    bag3 = ~Dir(prototype),
    bagn = ~Dir(prototype)
    
    observe(Discrete(colors, bag1), :blue, :blue, :black, :blue, :blue, :blue)
    observe(Discrete(colors, bag2), :blue, :green, :blue, :blue, :blue, :red)
    observe(Discrete(colors, bag3), :blue, :blue, :blue, :blue, :blue, :orange)
    
    # Posterior predictive.
    ~Discrete(colors, bagn)
end;
In [7]:
bar(posterior)
Out[7]:
x black blue green orange red -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 -1.00 -0.95 -0.90 -0.85 -0.80 -0.75 -0.70 -0.65 -0.60 -0.55 -0.50 -0.45 -0.40 -0.35 -0.30 -0.25 -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 -1 0 1 2 -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 p(x)
In [ ]: