Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

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:42
How can he win? 30 7:28
White Marble Probability 30 3:16
Boy or girl paradox 30
5:00
Is it a queen? 30
4:23
Bayes theorem
Problem Score Companies Time Status
Positive Test Probability 30 10:05
Chances to be spam 30
8:27
Probability of shares of a company 30
8:50
Covid probability (bayes) 100
16:34
Normal and continuous distribution
Problem Score Companies Time Status
Distribution Percentage 30 5:02
Random variables
Problem Score Companies Time Status
Product probability 30
10:17
Random variable's probability 30
5:53
New variance 30
6:39
Toss random variable 30
1:52
Probability distributions
Problem Score Companies Time Status
Standard deviation 30
2:35
Probability Distribution 50
20:37
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1992
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
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 *
1992
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
*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