Discrete Variables in emcee
See original GitHub issueHi,
First of all: Thanks for all the great work put into emcee!
I was wondering whether it would be possible to sample discrete variables with emcee. I have created a small example script that estimates the number of trials and probability of success for a binomial distribution here https://gist.github.com/lfloeer/d8a2d3ccc8898eeb02af
I achieve the discrete sampling by simply casting the parameter to int when calculating the likelihood. The results do look sensible, but I am unsure whether I’m introducing a bias of some sort. I imagine that rounding off a variable prior to likelihood computation is equivalent of having a stepwise likelihood and I can’t see anything wrong with that (apart from it not being continuously differentiable which makes optimization difficult/impossible).
My ultimate goal would be to perform model selection as described by @fonnesbeck in http://stronginference.com/bayes-factors-pymc.html
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (6 by maintainers)

Top Related StackOverflow Question
@yoavram: That’s right, but that will change what your bounds mean. For example, if you want a binary variable, you should set the bounds as
-0.5 < theta < 1.5whereas, if you’re flooring, you should use0 < theta < 2. This doesn’t matter so much for binary, but if you have more classes, it’ll matter more!Hi @dfm, quick question – there’s no advantage to rounding vs flooring the value, right?