How to Use Conditional Probability

Conditional Probability is an important component of learning Statistics, which is important to learn Machine Learning and Artificial Intelligence. In this post, you will learn about how to use conditional probability.

Events

To comprehend conditional probability, we first need to understand some essential terms used:

Event: It is the result of any random experiment conducted. Appearance of heads on tossing of a coin is an event. Receiving a 5 on throwing a fair die is also an event. To compute their probabilities, we specify the sample space and the events. An event may also be collection of different events clubbed together.

Sample space: It is a collection of every single accessible result in a trial. When we execute an activity over and over again, sample space contains an accumulation of all the achievable outcomes.

For instance: Sample space for random throw of a die is {1,2,3,4,5,6}. One of these will undoubtedly happen in the event of throwing a die. The sample space depicts each one of the conceivable outcomes that can happen when that trial is performed.

Independent, Dependent and Exclusive Events

Assume we have two events – Event A and Event B.

On the off chance that the occurring of event A doesn’t influence the occurring of event B, these events are called as independent events.

Let’s explore few cases of independent events:

  • Getting heads subsequent to flipping a coin AND getting a 5 on throw of a fair die.
  • Choosing a marble from a container AND getting heads in the flipping of a coin.
  • Choosing a 3 card from a deck of cards, placing it back, AND then picking an ace as the second card.
  • Rolling a 4 on a reasonable throw of a fair die, AND then rolling a 1 on another die.

In each of these cases the probability of result of the second event isn’t influenced at all by the result of the first event.

Probability of independent events

For this situation the probability of P (A ꓵ B) = P (A) * P (B)

We will take a case here for better understanding. Assume we win the challenge, if we pick a red marble from a jug containing 4 red and 3 dark marbles and we get heads on the flip of a coin. What is the probability of winning?

We characterize event A, as getting red marble from the jug.

Event B is getting heads on the flip of a coin.

We have to discover the probability of both, getting a red marble and a heads in a coin toss.

P (A) = 4/7

P (B) = 1/2

We realize that there is no effect of the marble color on the result of the coin toss.

P (A ꓵ B) = P (A) * P (B)

P (A ꓵ B) = (4/7) * (1/2) = (2/7)

Probability of dependent events

Next, think about the cases of dependent events?

In the above case, we characterize event A as getting a Red marble from the jug. We at that point keep the marble out and after that take another marble from the jug.

Mutually exclusive and exhaustive events

Mutually exclusive events are those events where two events can’t occur together.

The most straightforward case to comprehend this is the flip of a coin. Getting a head and a tail are mutually exclusive on the grounds that we can either get heads or tails but never both at the same time in one single coin toss.

An arrangement of events is on the whole exhaustive when the set ought to contain all the possible results of the trial. One of the events from the set must happen surely when the experiment is done.

For instance, in a fair die throw, {1,2,3,4,5,6} is an exhaustive collection since it includes the whole scope of the achievable outcomes.

Consider the results “even” (2,4 or 6) and “not-6” (1,2,3,4, or 5) in a throw of a fair die. They are collectively exhaustive but if you observe closely they aren’t mutually exclusive.

Conditional Probability

Conditional probabilities emerge normally in the examination of experiments where a result of a trial may influence the results of the upcoming trials.

We endeavor to compute the probability of the second event (event B) given that the primary event (event A) has just happened. On the off chance that the probability of the event changes when we mull over the primary event, we can securely say that the probability of event B is reliant on the occurrence of event A.

How about we consider situations where this happens:

  • Drawing a 2nd Ace from a deck of cards given we got the initial Ace.
  • Finding the probability of possessing a disease given you were tried positive.
  • Finding the probability of liking Harry Potter given we know the individual prefers fiction.

Here we can characterize, 2 events:

  • Event A is the probability of the event we’re attempting to ascertain.
  • Event B is the condition that we know or the event that has happened.

We can compose the conditional probability as P(A/B), the probability of the taking place of event A given that B has just happened.

How about we play a basic session of cards for you to comprehend this. Assume you draw two cards from a deck and you win in the event that you get a jack just after an ace (without any replacement). What is the probability of winning, given we are told you got a jack in the initial turn?

Let event A be getting a jack in the 1st turn.

And event B is a chance to get an ace in the 2nd turn.

We have to calculate P(B/A)

P(A) = 4/52

P(B) = 4/51 {no replacement}

P(A and B) = 4/52*4/51= 0.006

P(B/A) = P(A and B)/P(A) = 0.006/0.077 = 0.078

Here we are deciding the probabilities when we know a few conditions as opposed to calculating random probabilities. We are also aware that he got a jack in the first turn.

Let’s take another illustration.

Assume you have a jug containing 6 marbles – 3 dark and 3 white. What is the probability of getting a dark given the first was dark as well?

P (A) = getting a dark marble in the principal turn

P (B) = getting a dark marble in the second turn

P (A) = 3/6

P (B) = 2/5

P (A and B) = ½*2/5 = 1/5

P(B/A) = P(A and B)/P(A) = 0.2/0.5 = 0.4

Reversing the condition

Illustration: Rahul’s most loved breakfast is bagels and his most loved lunch is pizza. The probability of Rahul having bagels for breakfast is 0.6. The probability of him having pizza for lunch is 0.5. The probability of him, having a bagel for breakfast given that he has a pizza for lunch is 0.7.

How about we characterize event A as Rahul having a bagel for breakfast, Event B as Rahul having a pizza for lunch.

P (A) = 0.6

P (B) = 0.5

P(A/B) = 0.7

In the event that we take a close look at the numbers, the probability of having a bagel is unique in relation to the probability of having a bagel given he has a pizza for lunch. This implies the probability of having a bagel is reliant on having a pizza for lunch.

Imagine a scenario in which we have to know the probability of having a pizza given you had a bagel for breakfast, i.e. we have to know P(B/A). Bayes’ theorem now comes into the scene.

Bayes’ Theorem

The Bayes’ theorem portrays the probability of an event in light of the earlier information of the conditions that may be identified with the event. In the event that we know the conditional probability P(A/B), we can utilize the Bayes’ rule to locate the reverse probabilities P(B/A).

How to do that?

The above statement is the general portrayal of the Bayes rule.

For the last case – in the event that we now wish to ascertain the probability of having a pizza for lunch given you had a bagel to breakfast, would be = 0.7 * 0.5/0.6.
We can sum up the formula further.

On the off chance that various events Ai form an exhaustive set with another event B.

We can compose the equation as

Cases of Bayes Theorem and Probability trees

Consider the case of the melanoma patients. The patients were tried thrice before the doctor presumed that they had melanoma. Suppose that 1.48 out of a 1000 people have melanoma in the US at that specific time when this test was led. The patients were tried over various tests. Three arrangements of tests were done and the patient was declared to have melanoma on the off chance that he/she tried positive in every one of the three.

Inspecting the test in detail.

Sensitivity of the test (93%) – true positive rate

Specificity of the test (99%) – true negative rate

First, we figure the probability of having melanoma given that the patient tried positive in the 1st test.

P (has melanoma | first test +)

P (melanoma) = 0.00148

Sensitivity can be indicated as P (+ | melanoma) = 0.93

Specificity can be indicated as P (- | no melanoma)

Since we don’t have other data, we trust that the patient is a randomly tested person. Subsequently, our prior conviction is that there is a 0.148% probability of the patient having melanoma.

The other side says that there is a 100 – 0.148% possibility that the patient does not have melanoma.

We try to figure the probability of having melanoma given that he tried positive on the main test i.e. P (melanoma|+)

P(melanoma|+) = P(melanoma and +)/P(+)

P (melanoma and +) = P (melanoma) * P (+) = 0.00148*0.93

P (no melanoma and +) = P (no melanoma) * P(+) = 0.99852*0.01

To ascertain the probability of testing positive, the individual can have melanoma and test positive or he might not have melanoma and still test positive.

P(melanoma|+) = P(melanoma and +)/(P(melanoma and +) + P(no melanoma and +)) = 0.12

This implies there is a 12% possibility that the patient has melanoma given he tried positive in the principal test. This is known as the posterior probability.

Bayes Updating

We now try to figure the probability of having melanoma given the patient tried positive in the second test too.

Presently, recall that we will just do the second test in the event that she tried positive in the first. Accordingly, now the individual is not any more an arbitrarily tested individual yet a particular case. We know something about her. Henceforth, the prior probabilities should change. We refresh the prior probability with the posterior from the past test.

Nothing would change in the sensitivity and specificity of the test since we’re doing likewise test once more.

How about we compute again the probability of having melanoma given she tried positive in the second test.

P (melanoma and +) = P(melanoma) * P(+) = 0.12 * 0.93

P (no melanoma and +) = P (no melanoma) * P (+) = 0.88 * 0.01

To figure the probability of testing positive, the individual can have melanoma and test positive or she might not have melanoma and still test positive.

P(melanoma|+) = P(melanoma and +)/(P(melanoma and +) + P(no melanoma and +)) = 0.93

Presently we see, that a patient who tried positive in the test twice, has a 93% possibility of having melanoma.

Other uses of conditional probability

The formula for conditional probability can be changed using some fundamental algebra. Instead of below formula:

P(A | B) = P(A ∩ B)/P( B ),

we multiply the two sides by P( B ) and get the proportional equation:

P(A | B) x P( B) = P(A ∩ B).

We would then be able to utilize this equation to discover the probability that two events happen by using the conditional probability.

Use of Formula

This adaptation of the equation is most helpful when we know the conditional probability of A given B and in addition the probability of the event B. If so, at that point we can figure the probability of the of intersection A given B by essentially multiplying the two other probabilities. The probability of the intersection of two events is an essential number since it is the probability that both event happen.

Cases

For our first case, assume that we know the below values for probabilities:
P(A | B) = 0.8 and P( B ) = 0.5. The probability P(A ∩ B) = 0.8 x 0.5 = 0.4.

While the above case demonstrates how the formula functions, it may not be most helpful on how useful the above equation is. So, we will think about another case. There is a secondary school with 400 children, of which 120 are male and 280 are female.

Of the males, 60% are at present selected in a science course. Of the females, 80% are as of now selected in a science course. What is the probability that a randomly chosen student is a female who is enlisted in a science course?

Here, we let F indicate the event “Chosen student is a female” and M the event “Chosen student is enlisted in a science course.” We have to decide the probability of the intersection of these two events, or P(M ∩ F).

The above formula demonstrates that P(M ∩ F) = P( M|F ) x P( F ). The probability that a female is chosen is P( F ) = 280/400 = 70%. The conditional probability that the chosen student is enlisted in a science course, given that a female has been chosen is P( M|F ) = 80%. We multiply these probabilities together and see that we have an 80% x 70% = 56% probability of choosing a female student who is enlisted in a science course.

Test for Independence

The above formula relating conditional probability and the probability of intersection gives us a simple method to tell on the off chance that we are managing two independent events. Since events A and B are independent, if P(A | B) = P( A ), it takes after from the above equation that events A and B are independent if and only if:
P(A) x P(B) = P(A ∩ B)

So on the off chance that we realize that P(A) = 0.5, P(B) = 0.6 and P(A ∩ B) = 0.2, without knowing any other thing, we can conclude that these events are not independent. We know this since P( A ) x P( B ) = 0.5 x 0.6 = 0.3. This isn’t the probability of the intersection of A and B.

In this article, you learned about how to use Conditional Probability. Hope you found this article useful!

Comments are closed.


Magoosh blog comment policy: To create the best experience for our readers, we will only approve comments that are relevant to the article, general enough to be helpful to other students, concise, and well-written! 😄 Due to the high volume of comments across all of our blogs, we cannot promise that all comments will receive responses from our instructors.

We highly encourage students to help each other out and respond to other students' comments if you can!

If you are a Premium Magoosh student and would like more personalized service from our instructors, you can use the Help tab on the Magoosh dashboard. Thanks!