171. Bayes Theorem

Bayes Theorem

Bayes Theorem is about considering the posterior distribution considering prior distribution and currently available data.

Let’s say we want to predict a man’s occupation.
Is this man a librarian or a farmer given the following description?
– He likes to read books
– He likes to have his time quiet and alone
– He likes to spend time at the library

In most cases, most people would predict that the man is a librarian.
But wait, did you consider how many librarians are there compared to farmers in the first place..? This is what Bayes theorem is considering.

So instead, you first consider the current librarian-farmer ratio(Let’s say, 1:20). Then, given the description above, you predict that 55% of librarians fit that description and 30% of farmers fit that prediction.

The final probability would be…

P(Librarian Given Description) = (# of People)xP(H)xP(E|H) / (# of People)xP(H)xP(E|H) + (# of People)xP(NotH)xP(E|NotH)
P(H)= Prior Probability of being a librarian = 1/21
P(E|H)=Probability of those fitting the description given Prior Probability of being a librarian = 0.55
P(NotH)= Prior Probability of NOT being a librarian = 20/21
P(E|NotH) = Probability of those fitting the description given Prior Probability of NOT being a librarian = 0.30

Recommended Links – HERE