Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

Probability

Go to Problems

Bayes Theorem

The Bayes’ theorem describes the probability of an event based on prior knowledge of the conditions that might be relevant to the event. It tells us how to invert conditional probabilities, i.e. to find P(B|A) from P(A|B).

 

The formula for Bayes’ Theorem:

 

Example 1:

 

You are planning a picnic today, but the morning is cloudy

Oh no! 50% of all rainy days start off cloudy!

But cloudy mornings are common (about 40% of days start cloudy)

And this is usually a dry month (only 3 of 30 days tend to be rainy, or 10%)

 

What is the chance of rain during the day?

 

We will use Rain to mean rain during the day, and Cloud to mean cloudy morning.

So let's put that in the formula:

 

P(Rain|Cloud) = P(Rain) x P(Cloud|Rain) / P(Cloud)

P(Rain|Cloud) = 0.1 x 0.5 / 0.4 = 0.125

 

Or a 12.5% chance of rain. Not too bad, let's have a picnic!

 

Example 2 :

 

Imagine there is a drug test that is 98% accurate, meaning 98% of the time it shows a true positive result for someone using the drug, and 98% of the time it shows a true negative result for nonusers of the drug. Next, assume 0.5% of people use the drug.

 If a person selected at random tests positive for the drug, the following calculation can be made to see whether the probability the person is actually a user of the drug.

 

(0.98 x 0.005) / [(0.98 x 0.005) + ((1 - 0.98) x (1 - 0.005))] = 0.0049 / (0.0049 + 0.0199) = 19.76%

 

Bayes' theorem shows that even if a person tested positive in this scenario, it is actually much more likely the person is not a user of the drug.

 

Serious about Learning Data Science and Machine Learning ?

Learn this and a lot more with Scaler's Data Science industry vetted curriculum.
Conditional probability
Problem Score Companies Time Status
Probability of Raining 30
9:56
How can he win? 30
BCG
7:37
White Marble Probability 30 3:19
Boy or girl paradox 30
5:10
Is it a queen? 30
4:27
Bayes theorem
Normal and continuous distribution
Problem Score Companies Time Status
Distribution Percentage 30 5:07
Random variables
Problem Score Companies Time Status
Product probability 30
10:54
Random variable's probability 30
6:22
New variance 30
6:59
Toss random variable 30
2:08
Probability distributions
Problem Score Companies Time Status
Standard deviation 30
2:37
Probability Distribution 50
20:26
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test