Intro to Probability and Stats | Towards AI
@Bayes’ Theorem For Bae
Introduce someone to probability theory and statistics without scaring them off
Bayes’ Theorem is something that confuses and frustrates many, but is not as awful as many make it out to be. It is written out as:
P(A|B) = P(B|A)*P(A)/P(B),
where P(A) means the probability that event A occurs, and P(A|B) means the probability that event A occurs given that event B occurs (in other words, knowing that B occurs, the probability that A will occur).
While the formula for “Bae’s Theorem” given in the graphic above is silly, doesn’t make mathematical sense, and borders on being NSFW, it does help illustrate what the problem statement is (something that throws many, as intuitively it seems kind of backwards). Given that Netflix is occurring, one would want to know the probability of ‘chill’, NOT the other way around. Granted, the right side of the equation is complete nonsense, but the left-side is actually a good mnemonic device, especially given that part of the reason so many students tune-out while learning mathematics is due to the dry sterility of the presentation.
The theorem essentially states that: the probability of event A given event B is equal to the probability of B given event A times the probability of event A divided by the probability of B. Which seems very complex without breaking it down bit by bit. The best way to explain (and see the use of this) is to look at an example (which I have taken directly from a lab assignment from the DSI program hosted by General Assembly):
You work at a financial services company that offers individual retirement accounts (IRAs). To target high potential customers, you want to find out if people with children are more likely to invest in IRAs.
So far you have found:
- 30% of all Americans have IRAs.
- half of Americans have children.
- two-thirds of those with IRAs have children.
Based on this information, what is the probability that someone with children has an IRA?
You may (or may not) have noticed that the question is framed like the left-side of the equation for Baye’s Theorem: probability of event A (having an IRA) given event B (having children). Note that an ‘event’ doesn’t have to be an active fact; sometimes it just can represent possessing a quality. If we frame this question to fit the equation for Bayes’ Theorem and fill in the right side with the appropriate values, we have something like this:
P(IRA|Child) = P(Child|IRA)*P(IRA)/P(Child).
Then go back to the set up of the question:
30% of all Americans have IRAs is the same as saying the probability of having an IRA is 30%, or P(IRA) = 0.3
Half of Americans have children is the same as saying the probability of having children is 1/2, or P(Child) = 0.5
two-thirds of those with IRAs have children is the same as saying the probability of having children, given that the person has an IRA, is 2/3, or that P(Child|IRA) = 0.666
So ultimately, after somewhat advanced logical interpretation, the mathematical end of things is fairly straightforward algebraic plug n’ chug:
P(IRA|Child) = (0.666 * 0.3) / 0.5 = 0.4
Thus there is a 40% probability that someone with children has an IRA.
Did you follow along? Congratulations! You now understand a concept in statistics that trips up a large majority of data scientists. Math can be an intimidating and unpleasant experience for people who don’t naturally take to it, but when you demystify it and break it down into it’s components, most people can grasp even advanced concepts.