How to better visualize Bayes’ Theorem

by Shawn Berry

I often see Bayes’ Theorem presented in a satisfactory yet less-than-helpful manner.  Even Wikipedia has an inelegant solution.

First, Bayes’ Theorem simply says that the probability of A intersect B, written P(AB), equals the probability of A given B times the probability of B, written P(A|B) * P(B), and equals the probability of B given A times the probability of A, written P(B|A) *P(A).

Thus, P(AB) = P(A|B) * P(B) = P(B|A) * P(A).

Solving for P(A|B) yields P(B|A) * P(A) / P(B) as Wikipedia boxes in green.

Even more useful is P(A|B) = P(AB) / P(B), which we’ll use with the 2 x 2 chart below.  First notice that the Wikipedia solution uses 6 (typically inexact) floats in its next to last line.



In contrast, I always visualize Bayes’ Theorem with a simple 2 x 2 chart (see below).  For clarity, I continue with the same example.  First capture the stated Totals: 0.5% User and 99.5% Non-User.  Then multiply 0.005 by 0.99 (=.00495) to show that the test is 99% accurate in identifying a User with a Positive test result.  Similarly, multiply 0.995 by 0.99 (=.98505) to show that the test is 99% accurate in identifying a Non-User with a Negative test result:


Remember that P(A|B) = P(AB) / P(B) so P(User|+) = P(User+) / P(+).

Thus, P(User|+) = 0.00495 / 0.01490 = 0.33221.  In English, the probability that someone is a User given they had a Positive test result is only 1/3 (because False Positives are twice as likely as True Positives).

Although the weighted-average Accuracy is a stout 99%, Positive results are only 33% likely to be accurate — which most people would not expect from a test that is 99% likely to identify Users and 99% likely to identify Non-Users.  Remember this 33% Accuracy Rate for Positive results the next time you pee in a cup, have your blood taken, sit on a jury, or get medical results on any infrequent condition.  Be an informed consumer of statistics.  Start with a 2×2 chart to better visualize the data and, if possible, get a 2nd opinion or a 2nd test.  Cheers!



4 thoughts on “How to better visualize Bayes’ Theorem

  1. Excellent analysis! Another factor to consider is that cities with an undersupply of qualified workers would literally need to make room for the thousands of newcomers needed to meet Amazon’s hiring needs. There are already housing shortages in the cities you mention that could take years to address. This must be on Amazon’s mind because they would have to provide housing.


  2. Hi Adam, thank you for your comment. I wrote some housing and education suggestions to Amazon but then edited them to keep my analysis as short as possible. Yes, Amazon should insist that many condominiums be built nearby its headquarters so that its workers can build equity in these hot real estate markets. Notice that the San Francisco Shipyard and Candlestick area is much larger than the area proposed in Boston. No matter the city, it will take 10-15 years for Amazon to fully staff HQ2. Cheers, Shawn

    Liked by 1 person

  3. This was a good read. I like the fact that you were able to give a well balanced write up backed with data (not personal judgement). The major argument for San Francisco is the cluster that already exists there, newly graduating talent from Stanford, UC Berkeley, etc and the opportunity to lure talents from other tech companies. According to the stats in the article, Boston produces slightly more new tech talents than San Francisco despite SF having more tech focused institutions. I see Amazon as a company that would not want to fight for talent, which might make Boston attractive to them. If Amazon chooses Boston as the home of HQ2, I see a ripple effect where other tech companies follow suit. The Forecast is very much balance factoring all the pros and cons of each city. Love it!


    1. Hi Babatunde, thanks for your comment. Go Fuqua. It sounds like you would bet on Boston. SF costs 10-20% more for labor. Of course many tech companies already have satellite operations in Beantown. As you point out, Amazon choosing Boston would further boost Boston’s profile.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s