Beta probabilities

Fixed merge conflicts with master branch.
@caser this test is failing occasionally, I suspect due to the element of randomness involved, can you take a look at it?