The probabilities for drawing a red ball from a particular bag are:
P(red|bag1) = 3/5
P(red|bag2) = 5/9
The conditional probability that a variable X takes some value given that another variable Y takes some value, denoted as P(X|Y) is related to the joint probability as follows:
P(X,Y) = P(Y)*P(X|Y)
So, in P(X|Y) it is given that Y takes some vale and then you can consider the probability as a function of X given that Y has that known value. If you multiply that by the probability that Y has this value in the first place,
P(Y), then you get the joint probability P(X,Y).
In this case, each bag has a prior probability of 1/2, so the joint probability for drawing a red ball and having chosen a particular bag are:
P(red, bag1) = 1/2 * 3/5 = 3/10
P(red, bag2) = 1/2 * 5/9 = 5/18
Then to find the conditional probabilities for the ball coming from a particular bag, given that the ball was red, you need to divide the joint probabilities by the prior probability for the ball being red, P(red.
We can obtain P(red) from summing the joint probabilities over all the bags:
P(red) = P(red, bag1) + P(red, bag2) =
3/10 + 5/18 = 26/45
P(bag1|red) = P(red, bag1)/P(red) =
P(bag2|red) = P(red, bag2)/P(red) =