Problem about choice of balls from an urn with Bayes rule An urn contains 2N balls numbered from 1 to 2N. An experiment with It consists of choosing, randomly and without replacement, two balls from the ballot box, consecutively. Calculate the probability that the first choice results in an even number under the hypothesis that the sum is even.
The solution gives by the book is:
Consider the following events:
B: the sum of the two chosen numbers is even.
A1: the number of the first choice is even.
A2: The number of the second choice is odd.
So:
$$P(A_{1}|B)= \frac{B|P(A_{1})P(A_1)}{P(B|P(A_{1})P(A_{1})+P(B|P(A_{2})P(A_{2})}=\frac{1}{2}$$
I know some probability, but I'm confused.
Now I understand it was used the Bayes rule, but I don't understand very well why the events chosen was A1 and A2, because missing cases where the first choice is odd(A3) and the second is even(A4), I think this is because if the event A1 and A2 can't happen if B already happened. But I'm not sure about that.
Besides that, I don't know how calculate P(A1), P(B|A1), and P(B|A2). One of my options was that $P(A1)=\frac{N}{2N}=\frac{1}{2}$ because in the first choice half is even and $P(A2)=\frac{N}{2N-1}$ because an even ball was obtained after the first option, so now there are same odd balls but
now there are fewer balls in total. But I don't know how get P(B|A1) only with that.
Maybe I'm wrong in all of that.
Thank you very much.
 A: I think you need to step back and think about this a bit more intuitively.
Suppose I first draw one number $X_1$ without replacement from $\{1, 2, \ldots, 2N\}$.  Then, from the remaining numbers, I draw a second number $X_2$.  If $X_1 + X_2$ is odd, I put the numbers back and start over.  If $X_1 + X_2$ is even, I stop, and I ask you to guess whether $X_1$ is even or odd.
Now, given that $X_1 + X_2$ is even--you are not asked anything about $X_1$ otherwise--you know that $X_1$ and $X_2$ must share the same parity; i.e., they are either both even, or both odd.  But since there are just as many even numbers as there are odd numbers from the list, intuition suggests that the "even/even" case is equally likely as the "odd/odd" case.  Therefore, the probability that $X_1$ is even given that the sum is even, should be $1/2$.
For more support of this intuition, let us consider a small case, say $N = 2$.  Then our list is $\{1, 2, 3, 4\}$ and there are only four ways to draw two numbers without replacement such that their sum is even:  $$(X_1, X_2) \in \{(1,3), (2,4), (3,1), (4,2)\}.$$  In exactly half of these cases, $X_1$ is even.
So let's now turn to the Bayesian reasoning.  Define the event $A_i$ to represent the outcome that $X_i$ is even, so that $\bar A_i$ is the complementary event that $X_i$ is odd, for $i \in \{1, 2\}$.  now define $B$ to represent the outcome that $X_1 + X_2$ is even.  We want to compute $\Pr[A_1 \mid B]$, the probability that $X_1$ is even given $X_1 + X_2$ is even.  Then a straightforward application of Bayes' theorem yields $$\Pr[A_1 \mid B] = \frac{\Pr[B \mid A_1]\Pr[A_1]}{\Pr[B]}.$$  The denominator is the unconditional or marginal probability of event $B$, which can be expanded using the law of total probability:  $$\Pr[B] = \Pr[B \mid A_1]\Pr[A_1] + \Pr[B \mid \bar A_1]\Pr[\bar A_1].$$  That is to say, we conditioned event $B$ based on whether $X_1$ is odd or even.  If $X_1$ is even, then we require $X_2$ to also be even.  In other words, $\Pr[A_1] = \Pr[\bar A_1] = \frac{1}{2}$ is obvious, but $$\Pr[B \mid A_1] = \Pr[A_2 \mid A_1] = \frac{N - 1}{2N - 1},$$ because once you have drawn an even number, there are only $N-1$ remaining even numbers to select out of $2N-1$ numbers.  Similarly, $$\Pr[B \mid \bar A_1] = \Pr[\bar A_2 \mid \bar A_1] = \frac{N - 1}{2N - 1}.$$  The rest is simple substitution:  $$\Pr[A_1 \mid B] = \frac{\frac{N-1}{2N - 1}\cdot \frac{1}{2}}{\frac{N-1}{2N - 1}\cdot \frac{1}{2} + \frac{N-1}{2N - 1}\cdot \frac{1}{2}} = \frac{1}{2}.$$  But our earlier intuition shows why this kind of formal computation is unnecessary--it is the symmetry of even/odd numbers in the list that shows why the probability is $1/2$.

As an exercise, then, suppose the list is actually $\{1, 2, \ldots, 2N + 1\}$.  That is to say, it is not longer the case that there are as many even numbers as odd ones.  How does this affect the resulting probability?  How would you generalize it to the case where the list contains arbitrary distinct integers, say $a$ odd numbers, and $b$ even numbers?
