# RandomVariate and Map, strange behavior noticed

I'm performing Bayesian Analysis and I have written this piece of code

successes = 6; trials = 16;
samples = 20000;
(*prior = BinomialDistribution[trials, 0.333];*)
prior = UniformDistribution[{0, 1}];
priorsamples = RandomVariate[prior, samples];
model[theta_] := BinomialDistribution[trials, theta];
delta = 0.05;
bins = Table[i, {i, 0, 1, delta}];
priorbin = BinCounts[priorsamples, {bins}];
generated = {priorsamples,
RandomVariate[#] & /@ (model[#] & /@ priorsamples)}\[Transpose];
posteriorsamples = (Select[
generated, #[] == successes &]\[Transpose])[];
posteriorbins = BinCounts[posteriorsamples, {bins}];
Show[
Plot[-1, {x, 0, 1}],
Graphics[{EdgeForm[Black], FaceForm[{Opacity[0.5], Red}],
Rectangle[{#[],
0}, {#[] + delta, #[]/samples/
delta}] & /@ ({bins[[1 ;; -2]], priorbin}\[Transpose])}],
Graphics[{EdgeForm[Black], FaceForm[{Opacity[0.5], Blue}],
Rectangle[{#[],
0}, {#[] + delta, #[]/Length[posteriorsamples]/
delta}] & /@ ({bins[[1 ;; -2]],
posteriorbins}\[Transpose])}],
PlotRange -> {{0, 1}, {0, 5}}
]


using UniformDistribution I have no problem. Using BinomialDistribution (uncomment the corresponding line) I got the following error that should occur when Mathematica computes generated by processing RandomVariate and Map. I'm runnning version 10.3 under Ubuntu 16.04. Could you reproduce this error?

Thanks for the help!

• Yes, I reproduce the error. Is it so strange? If prior = BinomialDistribution[trials, 0.333] then sampling from prior will certainly give integers, and almost certainly some larger than 1. You then feed these samples back to model as the probabilities p for a single "success" in a binomial sampling. Is this really intended? It does not make sense to me. – Marius Ladegård Meyer Apr 19 '17 at 19:57
• you're right. I did not mean to do that, I meant feeding a beta! Now I see. – Fabio Apr 19 '17 at 20:07