oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Conditional Probability #417

Open oldoc63 opened 2 years ago

oldoc63 commented 2 years ago

If we want to calculate the probability that a pair of dependent events both occur, we need to define conditional probability. Using a bag of marbles as an example, let's remind ourselves of the definition of dependent events:

Image

oldoc63 commented 2 years ago

If we pick two marbles from a bag of five marbles without replacement, the probability that the second marble is red depends on the color of the first marble. We have a special name for this: conditional probability. Conditional probability measures the probability of one event occurring, given that another one has already occurred.

Notationally, we denote the word "given" with a vertical line. For example, if we want to represent the probability that we choose a red marble given the first marble is blue, we can write:

$$ P(Red Second | Blue First) $$

From the above diagram we know that $P(Red Second|Blue First) = 3/4$.

What if we picked out two marbles with replacement? What does the conditional probability looks like? Regardless of which marble we pick up first, it will be put back into the bag. Therefore, the probability of picking out a red marble or a blue marble second is unaffected by the first outcome.

Teherefore, for independent events, we can say:

$$ P(A|B) = P(A) $$

and

$$ P(B|A) = P(B) $$