This is a simple implementation of Expectation-Maximization Algorithm given by Do and Batzoglou as coin-tossing game
For more information and the description of EM algorithm please read What is the expectation maximization algorithm? by Do and Batzoglou Link
You should read something like this, which corresponds to the illustration shown above.
You can play around with the initial parameters, just to make sure that you have a prior information that θ(A) should be greater or equal to θ(B).