Learning probability bad reasoning. Conditional and unconditional I have a problem, I'm learning probability at the moment (I'm a programmer) and starting I have this:

(Source: Minka.) My neighbor has two children. Assuming that the gender of a child is like a coin flip, it is most likely, a priori, that my neighbor has one boy and one girl, with probability 1/2. The other possibilities—two boys or two girls—have probabilities 1/4 and 1/4.

*

*a. Suppose I ask him whether he has any boys, and he says yes. What is the probability that one child is a girl?


*b. Suppose instead that I happen to see one of his children run by, and it is a boy. What is the probability that the other child is a girl?

Now my reasoning is:
BB = 1/4 = 0.25
BG = 1/4 = 0.25
GB = 1/4 = 0.25
GG = 1/4 = 0.25

So for a., the probability of G I get it just by summing p(B,G) + p(G,B) = 0.5
And for b. p(G|B) = p(G,B)/p(B) = 0.5/0.5 = 1 that is wrong but I'm not getting why.
 A: Another way to show this (part a ) is to write the Bayes rule as follows:
P(B|G) = P(G)P(B|G)  / P(~G)P(B|~G) + P(G)P(B|G)
       = (0.5 * 0.5) / (0.5*0.25 + 0.5*0.5) = 2/3
A: For (a), a simple way to look at is that you've reduced your probability space to only the combinations that have at least one boy:
BB = 1/3
BG = 1/3
GB = 1/3

GG is no longer a possibility based on the fact that your neighbor said he had at least one boy.  Of the possibilities remaining, you're left with a 2/3 probability that he has a girl.  The information he gave you reduced the probability of him having a girl from 3/4 to 2/3. Formally, this can be shown as follows:  $$P(At\ least\ one\ girl|At\ least\ one\ boy) = \frac{P(At\ least\ one\ girl\ \cap At\ least\ one\ boy)}{P(At\ least\ one\ boy)}  $$
From your original box, we can see the probability of having at least one boy and at least one girl is BG + GB = 0.25 + 0.25 = 0.5, but we need to divide by the probability of at least one boy, which is BB + BG + GB = 0.25 + 0.25 + 0.25 = 0.75, so we get $\frac{\tfrac{1}{2}}{\tfrac{3}{4}} = \frac{2}{3}$.
For (b), now that we've seen a boy, the only uncertainty remaining is the gender of the other child, and given no other information, the probability of the other child being female is 1/2, which is the answer.
