A machine makes coins that land heads with probability p and tails with probability 1−p. Here p is a number between 0 and 1, and the machine has no setting for it. The machine picks p at random while it makes a coin, so p is uniform on the interval [0,1].
The machine made two coins. Coin 1 has probability p and coin 2 has probability q. Both p and q are uniform on [0,1] and independent of each other, and there is no way to read off their actual values.
Coin 1 was tossed n1 times and came up heads m1 times. Coin 2 was tossed n2 times and came up heads m2 times. Given these observations, write a program that computes the probability that p<q.