So the first thing is to think about, and start to understand Bayes' Theorem.
You can try reading here for a start
http://en.wikipedia.org/wiki/Bayes%27_theorem
Theres lots of detail, and an example given.
It deals with conditional probability, so that is, that probability of somehthing happening, A say, given that B has already happened.
In equation form, it is writen
$$ P(A|B) = \frac{P(B|A) * P(A)}{P(B)}$$
which is read,
"The probability of A happening, given that B has already happened, is the probability of B happening, given that A has already happened, multiplied by the probability of A happening, all divided by the probability of B happening"
I usually try to think about these problems 'backwords', that is, start from the event we are interested in and the given condition, and then try to calculate what would be needed for that event to happen.
To think about a simple classic example. Whenever I get confused about this stuff, I always go back to this problem to set me thinking correctly.
Imagine you have three drawers, each of which has two coins inside.
Let one of the drawers have 1 silver coin, and 1 gold coin.
Let one of the drawers have 2 silver coins.
Let the third drawer have 2 gold coins.
We don't know which drawer has the two gold coins.
Then say I tell you that I open a drawer at random, and remove a coin, at random, and that the coin turned out to be a gold coin.
Then my question is, what is the probability that I took that coin out of the drawer which had two gold coins?
That is to say, what is the probability that the coin in my hand came from the third drawer, in those described above, given that it is gold.
Well, firstly, let's think about the fact that it cannot have possibly come from the second drawer, aggreed?
So that leaves us with two options for a drawer.
Now, the easiest thing to do in these problems when there are only a finite number of outcomes is to write all possible events out.
So to get a gold coin in my hand, one of three different things could have happened.
Firstly, I could have opened the first drawer, and then picked the single gold coin, yes?
Alternatively I could have opened the third drawer, and picked one of the coins in it, the one on the left for arguements sake, yes?
Or finally, I could have opened the third drawer, and picked the other coin in that drawer, the one on the right for arguements sake, yes?
So we see that one of three things had to happen, given that I have a gold coin in my hand.
But two of those things came from the event that I am interested in, namely my coin came from the drawer that had two gold coins inside of it.
Thus we conclude that the probability is 2/3. At first, a supprising result, no!
Does that make sense?
Hopefully you understand what we go about doing better now.
Next, lets move on to your original question.
So, here we want the probability that Stock did better than average, given that it was rated a good buy.
This is the same as asking, "what fraction of those that were rated good did better than average".
So again, lets look at all the posibilities.
There are thee things that can happen to a Stock which was rated as good. It can either
a) have been rated good, and done better
or
b) have been rated good, and done average
or
c) have been rated good, and done worse
Lets say we have N Stocks. Then the cases a), b) and c) happen for (I assume you understand basic probability, yes?)
a) $$0.40 \times 0.25 N = 0.1N $$
Stocks, or
b) $$0.20 \times 0.50 N = 0.1N $$
Stocks, or
c) $$0.1 \times 0.25 N = 0.025 N $$
Stocks.
Thus summing these, a total of $0.225N$ Stocks were rated good.
Then those that did better were
$$0.40 \times 0.25 N = 0.1N $$
of the Stock. so given that they were rated good, our probability is,
$$P = \frac{0.1 N}{0.225N}$$
or
$$ P = \frac{4}{9} = 0.44444 $$
So to recap, what we did, and the method that you should follow, is work out all the possibilties for your given condition, in this case, 'was rated good', and then take the fraction of events that you are interested in, in this case 'did better than average'.
This way of thinking will lead to far less mistakes than blindly trying to use the formula.
I hope this helps!
This is my first answer, and you said you wanted an explination of each step, so I hope I didn't go on for too long!
The law of total probability is used in Bayes theorem:
$P(A|B)=\frac{P(A\cap B)}{P(B)} \implies P(A\cap B) = P(B)P(A|B).$ This is just the definition of conditional probability.
Now, the Law of Total Probabiliyy can be used to calculate $P(B)$ in the above definition. The law requires that you have a set of disjoint events $D_i$ that collectively "cover" the event $B$. Then, instead of calculating $P(B)$ directly, you add up the intersection of $B$ with each of the events $E_i$:
$P(B)=\sum P(B\cap E_i)$ Of course, we can rewrite this using the definition of conditional probability:
$P(B)=\sum P(B\cap E_i)=\sum P(E_i)P(B|E_i)$
Thus, the following are equivalent:
$P(B|A)= \frac{P(A\cap B)}{P(A)} = \frac{P(B)P(A|B)}{P(B)P(A|B)+P(\neg B)P(A|\neg B)}$ Since $B$ and $\neg B$ are disjoint events.
In general, Bayes' rule is used to "flip" a conditional probability, while the law of total probability is used when you don't know the probability of an event, but you know its occurrence under several disjoint scenarios and the probability of each scenario.
Best Answer
Taking it one step at a time: $$\begin{align} \mathsf P(R\mid H, S) & = \frac{\mathsf P(R,H,S)}{\mathsf P(H, S)} \\[1ex] & =\frac{\mathsf P(H\mid R,S)\,\mathsf P(R, S)}{\mathsf P(H, S)} \\[1ex] & =\frac{\mathsf P(H\mid R,S)\,\mathsf P(R\mid S)\,\mathsf P(S)}{\mathsf P(H, S)} \\[1ex] & =\frac{\mathsf P(H\mid R,S)\,\mathsf P(R\mid S)}{\mathsf P(H\mid S)}\frac{\mathsf P(S)}{\mathsf P(S)} \\[1ex] & =\frac{\mathsf P(H\mid R,S)\;\mathsf P(R\mid S)}{\mathsf P(H\mid S)} \end{align}$$