Probability inference I am new to probability. I am working on this problem, but I am not sure if my approach is right. I'd really appreciate it is someone could please help me. Here is the problem:
A bag contains a pen which is either red or blue. I put a red pen inside the bag and shake it. Then, I take a pen out of the bag which is red. You are supposed to guess the color of the pen remained in the bag. What is the probability that the pen remained in the bag is also red?
So I think there are two different possibilities here: 


*

*the pen which we took from the bag, is the one when put inside, in that case the probability that the pen remained in the bag is also red, is 1/2. 

*The pen which we took from the bag, is not the one we put inside. So the probability that the pen remained in the bag is red, is 1. 
Now if we add this to possibilities, we get 1.5 > 1 and it's clearly wrong! I don't understand why though. 
 A: The problem is that you need to multiply the two different scenarios with their respective probability of them happening.
So, following your analysis, we could define the following events:
$R$: the pen that remains in the bag is red
$S$: the pen that you grab from the bag is the same as the one you put in
Then: $$P(R)=P(R \cap S) + P(R \cap S^C) = P(S)\cdot P(R|S) + P(S^C)\cdot P(R|S^C)$$
OK, so what is the probability $P(S)$ that the pen you took out of the bag is the same one you put in?  You might well think it is $\frac{1}{2}$. Indeed, normally, if we add a new object to an old object, and randomly pick one back out, we indeed have a $\frac{1}{2}$ chance of picking the one we just put in.  
However, remember that you were told that the pen you got out is red. That changes things. Indeed, given that the pen you took out is red, that's actually a clue that this probability could well be higher. 
Indeed, let's pump some intuitions here: suppose you had any non-red pens in the bag initially. Then given that you put in a red pen, and also got out a red pen, the probability that the pen you got out is the same as the pen you put in is higher than simply $1$ divided by the number of pens .. because the pen you got out clearly cannot be any of the non-red pens.  Indeed, if the pen originally in the bag was blue, then the probability that the pen you took out (and which was red) was the same one as the one you put in (which was also red), will be $1$!
Now, we don't know if the pen that was initially in the bag was not red .... but it could have been! And if so, it was certain for the pen you got out to have been the same pen as you put in. So again, this is why intuitively, the probability that the pen you got out is the same one you put in is actually higher than $\frac{1}{2}$.
OK, but then what is it? What is $P(S)$?
Well, let's define another event:
$B$: the pen that was originally in the bag is blue
With that, we could do:
$$P(S) = P(S \cap B) + P(S \cap B^C) = P(S | B) \cdot P(B) + P(S | B^C) \cdot P(B^C)$$
But this would not take into account that we were given that you drew a red pen. So, let's explicitly define that event:
$DR$: the pen you draw is red
And, instead of calculating $P(S)$, let's calculate what we should be calculating, which is $P(S|DR)$:
$$P(S|DR) = P(S \cap B|DR) + P(S \cap B^C|DR) =$$
$$P(S | B \cap DR) \cdot P(B|DR) + P(S | B^C \cap DR) \cdot P(B^C|DR)$$
Now, we know a few things:
$P(S | B \cap DR) = 1$ (if original is blue, and you draw red, then it is certain you drew the one you put in)
$P(S | B^C \cap DR) = \frac{1}{2}$ (if original is red, and you draw red, then probability is $\frac{1}{2}$ that the one you drew is the one you put in)
OK, but now what about $P(B|DR)$ and $P(B^C|DR)$?
Well:
$P(DR) = P(DR \cap B) + P(DR \cap B^C) = P(DR|B)\cdot P(B)+ P(DR|B^C)\cdot P(B^C)$
where:
$P(DR|B)=\frac{1}{2}$ (if original is blue, then chance of drawing red is half)
$P(DR|B^C)=\frac{1}{2}$ (if original is red, then chance of drawing red is 1)
and of course we do have: $P(B)=P(B^C)=\frac{1}{2}$
So:
$$P(DR) = \frac{1}{2} \cdot \frac{1}{2}+1\cdot  \frac{1}{2} = \frac{3}{4}$$
OK, now notice that:
$$P(B \cap DR) = P(B|DR)\cdot P(DR)$$
but also:
$$P(B \cap DR) = P(DR|B)\cdot P(B)$$
So:
$$P(B|DR)\cdot P(DR)=P(DR|B)\cdot P(B)$$
and so:
$$P(B|DR)=\frac{P(DR|B)\cdot P(B)}{P(DR)}$$
(this is how you derive Bayes' Law)
So:
$$P(B|DR)=\frac{\frac{1}{2}\cdot \frac{1}{2}}{\frac{3}{4}} = \frac{1}{3}$$
and so we then also have that: $P(B^C|DR)=1-P(B|DR)=\frac{2}{3}$
.. which is interesting: The a priori chance $P(B)$ of the orignal pen being blue is $\frac{1}{2}$, but given that you drew a red pen, the probability that the original was blue is now less than $\frac{1}{2}$
OK, and so now we can finally calculate the chance of you having drawn the same pen you put in, given that the pen you took out was red:
$$P(S|DR) = P(S | B \cap DR) \cdot P(B|DR) + P(S | B^C \cap DR) \cdot P(B^C|DR) =$$
$$1 \cdot \frac{1}{3} + \frac{2}{3}\cdot  \frac{1}{2} = \frac{2}{3}$$
Aha!  That confirms our earlier intuition that there is indeed a more than $\frac{1}{2}$ chance that the pen you got out is the pen you put in.
Finally, then, we can calculate the chance of the remaining pen being red.
Now, before we said that:
$$P(R)=P(S)\cdot P(R|S) + P(S^C)\cdot P(R|S^C)$$
but given that we drew a red pen, what we really need to calculate is:
$$P(R|DR)=P(S|DR)\cdot P(R|S\cap DR) + P(S^C|DR)\cdot P(R|S^C\cap DR)$$
OK, we just calculated:
$P(S|DR)=\frac{2}{3}$, and so it follows that $P(S^C|DR)=1-P(S|DR)=\frac{1}{3}$
Also, we know that $P(R|S \cap DR) =\frac{1}{2}$, since if the pen you drew is the same as the one you put in, then the chance of the remaining one being red is just the very same probability if it having been red in the first place, which is half.  The fact that the pen you drew is red is no longer relevant here: the fact that you took out the same one as you put in means it is just the a priori chance of it being red.
Finally, we have that $P(R|S^C\cap DR)=1$: if the pen you took out is not the same as you put in, then given that you put in a red one, the probability of the remaining one being red is of course just $1$ (as you yourself reasoned)
OK, so:
$$P(R|DR)=P(S|DR)\cdot P(R|S\cap DR) + P(S^C|DR)\cdot P(R|S^C\cap DR)=$$
$$\frac{2}{3}\cdot \frac{1}{2} + \frac{1}{3}\cdot  1 = \frac{2}{3}$$
Whew! That was a long haul!  
A: Let $x_0 \in {B,R}$ denote the color of the pen initially in the bag. Let $x_1 \in {B,R}$ denote the color of the pen drawn after adding a red pen and shaking it. Let $x_2 \in {B,R}$ denote the color of the pen remaining in the bag. We are interested in calculating $P(x_2=R|x_1=R)$. By Baye's rule and the law of total probability, we can write:
$P(x_2=R|x_1=R) = \frac{P(x_2=R,x_1=R)}{P(x_1=R)}  = \frac{P(x_2=R,x_1=R|x_0=R)P(x_0=R)+P(x_2=R,x_1=R|x_0=B)P(x_0=B)}{P(x_1=R|x_0=R)P(x_0=R)+P(x_1=R|x_0=B)P(x_0=B)}$.
If $x_0=R$, i.e. the initial pen in the bag was red, after adding another red pen, the probability of drawing a red pen is 1, i.e. $P(x_1=R|x_0=R)=1$. Also, in this case, the ball remaining in the bag is red, implying $P(x_2=R,x_1=R|x_0=R)=1$.
If $x_0=B$, i.e. the initial pen in the bag was blue, after adding another red pen, the probability of drawing a red pen is 0.5, i.e. $P(x_1=R|x_0=B)=0.5$. Also, in this case it is not possible that the ball drawn and the ball in the bag are both red, i.e. $P(x_2=R,x_1=R|x_0=B)=0$.
Further, we have to assume that the pen initially in the bag is equally likely to be blue or red, i.e. $P(x_0=R)=P(x_0=B)=0.5$.
Plugging the above results in, we get:
$P(x_2=R|x_1=R) = \frac{1 \times 0.5}{1 \times 0.5 + 0.5 \times 0.5} = \frac{2}{3}$.
