How to calculate conditional probability for balls in a two boxes? There are two boxes. In one of them there are $a$ white and $b$ black balls, and in the other one there are $b$ white and $a$ black balls ($a>b$).
One ball is being selected from a random box and put into the other box. After that, another ball is selected from the box with a new ball and it turns out to be white. What is the probability that this white ball has been selected from the box with initially $a$ white balls?
I'm trying to solve it, but I can't fully understand the conditional probability formula. 
I thought that $A$ may be the event that we've selected a ball from the box with initially $b$ white balls, $B$ - that we've chosen a white ball at the end. Then I'd like to find $P(A|B)$. But I don't know what is $P(A\cap B)$ in this case...
 A: The first box has $a$ white and $b$ black, the second box has $b$ white and $a$ black. One ball is either moved from the first box to the second (with probability $1/2$) or from the second box to the first (also probability $1/2$). You then select a ball from the box to which a ball was added. You are looking for the probability that the box you select from is the first box, given that it is white. 

Let $A$ be the event that the box you select from is the first box. Since both boxes are equally likely to be the box that is added to, $P(A) = 1/2$. 
Let $B$ be the event that the ball you select is white. By symmetry, $P(B) = 1/2$. 

You're looking for $P(A \mid B$), so you apply Bayes' theorem: $$P(A \mid B) = \frac{P(B \mid A) \cdot P(A)}{P(B)}$$
Since $P(A) = P(B) = 1/2$, this means $$P(A \mid B) = P(B \mid A)$$
$P(B \mid A)$, the probability that the ball is white, given that you choose from the first box, is considerably easier to calculate. The fact that you choose from the first box means that a ball was taken from the second box and put into the first.

The probability $P(W)$ that a white ball was taken from the second box and added to the first is $$P(W) = \frac{b}{a+b}$$
The probability $P(B)$ that a black ball was taken from the second box and added to the first is $$P(B) = 1 - P(W) = \frac{a}{a+b}$$

Now, we write $P(B \mid A)$ in terms of $P(W)$, $P(B)$, $a$, and $b$:
$$P(B \mid A) = P(W) \cdot \frac{a+1}{a+b+1} + P(B) \cdot \frac{a}{a+b+1}$$
The terms multiplied by $P(W)$ and $P(B)$ are the probabilities of getting a white ball, given a white-ball-transfer and a black-ball-transfer, respectively. In each case, this is just the number of white balls in the first box, divided by the total number of balls in the first box. 
$$P(B \mid A) = \frac{b}{a+b} \cdot \frac{a+1}{a+b+1} + \frac{a}{a+b} \cdot \frac{a}{a+b+1}$$
$$P(B \mid A) = \frac{a^2 + ab + b}{a^2 + 2ab + b^2 + a + b}$$
Finally,
$$P(A \mid B) = \frac{a^2 + ab + b}{a^2 + 2ab + b^2 + a + b}$$
