Hey Developer’s, I’m back with a new topic which is Bayes Theorem in the series of statistics foundations.

### Quick Refresher

**Law of Total Probability:**

If B1,B2,B3,⋯ is a partition of the sample space S, then for any event A we have,

So, let’s get started …

### Bayes Theorem

It is a way of finding a probability when we know certain other different probabilities. Basically calculates the probability of an event, based on the prior knowledge of conditions that might be related to the event.

where A and B are events and P(B) ≠ 0.

**P(A|B)**is a conditional probability, the likelihood of an event A occurring given that B is true.is a conditional probability, the likelihood of an event B occurring given that A is true.**P(B|A)****P(A)**and**P(B)**are the probabilities of A and B respectively.

### Example Of Bayes Theorem

**Example 1** : How search engines provides us the result ?

If we search for “Mobile Phones Under 10K”. Does the search engine know the mobiles under 10K ? No, but it knows from a lot of other searches what people are probably looking for and it calculates this on the basis of Bayes Theorem and shows us the relevant content.

**Example 2 :** Thanks to mathisfun for this example.

Let us say P(Fire) means how often there is fire, and P(smoke) means how often we see smoke, then:

P(Fire | Smoke) means how often there is fire when we can see smoke.

P(Smoke|Fire) means how often we can see smoke when there is fire.

So the formula kind of tells us “forwards” P(Fire|Smoke) when we know “backwards” P(Smoke|Fire).

Example:

- dangerous fires are rare (1%)
- but smoke is fairly common (10%) due to barbecues,
- and 90% of dangerous fires make smoke

We can then discover the **probability of dangerous Fire when there is Smoke**:

P(Fire|Smoke) = (P(Fire)P(Smoke|Fire))/P(Smoke) = (1% * 90%)/10% = 9%

So it is still worth checking out any smoke to be sure.

**Example 3: Picnic Day**

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.

The chance of Rain given Cloud is written P(Rain|Cloud)

So let’s put that in the formula:

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

- P(Rain) is Probability of Rain = 10%
- P(Cloud|Rain) is Probability of Cloud, given that Rain happens = 50%
- P(Cloud) is Probability of Cloud = 40%

P(Rain|Cloud) =( *0.1 x 0.5***)****/** 0.4 = .125

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

#### Next Post will be on Random Variables and Discrete Random Variables

Till then, Stay Connected

Connect with me on :

Linkedin: https://www.linkedin.com/in/patidarparas13/

Twitter: https://twitter.com/patidarparas13

MLAIT On Twitter: https://twitter.com/mlait1908

MLAIT On Linkedin: https://www.linkedin.com/company/mlait1908

MLAIT On Telegram: https://t.me/mlait

MLAIT On WhatsApp: https://chat.whatsapp.com/IDTD8ONgeZw2InepJEKrM7