Bayesian bandit calculation

Replaces #114: rebased and refactored.

/cc @lotze