Google Classroom
GeoGebraGeoGebra Classroom

A simple Bayesian probabilities calculator

Bayes' rule

How to use the applet

You can interact with the applet by simply modifying the numerical values in the 3 blue input boxes. Since they represents probabilities please ensure that you enter values between 0 and 1, or equivalently, 0% and 100%.

Bayes theorem and the prior/posterior probabilities

Bayes' theorem can be challenging and sometimes a little counterintuitive. Yet it is an important tool for updating "prior beliefs" with new evidence to form "updated beliefs”, leading to a more accurate understanding of the situation under consideration. Here's my attempt to show its inner workings. It is inspired by a clinical scenario but is also easily extendable to other completely different situations. Suppose there is a disease D and we make a clinical test T to get some information whether the patient has the disease or not. Here the variables are D and T that can assume the values D+/D- and T+/T- meaning that the disease is present/absent and the test used to detect the disease is positive/negative. At the core of Bayes’ theorem there is the Bayes rule, stating that (or, in general, ) Above formula means that the probability of D+ in case of a positive test is equal to the general probability of D+ (without test) times the factor (likelihood(1)). Above formula can be easily derived if we use the product rule for the probability of the intersection of two events: ) (use the 2nd and 3rd members and derive ). This allows us to write the Bayes rule in a different way: It’s also interesting to note that the multiplicative factor can also be rewritten as that is the ratio of the actual intersection probability with the probability we’d have in case of perfect independence between the two events. If this ratio is greater than 1 then the new evidence (T+) will produce an increase in the belief of D+. If it equals 1 then the new evidence (T+) has no effect in modifying the prior belief. If it is between 0 and 1 then the evidence will produce a decrease of D+ (and an increase in the belief of the contrary event D- ). (1)Actually the likelihood should be defined as considering T fixed (at T+ or T-) and D variable (assuming the possible values D+ or D- ). Here it is

Applications in different context (exercises)

1) Based on the evidences collected during the initial investigations a suspect, Peter, is considered guilty with a probability . The crime took place in a mountain resort where the sun coverage in that day was . But Peter claims to have spent the day of the crime at the seaside, where the sun coverage was Now a witness recalls that Peter had a noticeable tan the day after the crime. How will this new evidence impact the prior probability of Peter’s guilt? Answer: (After the new evidence Peter will probably be acquitted) 2) Sophie has organized an outdoor party on June 23rd to celebrate her graduation in Mathematics. However, she doesn't want her party to be spoiled by rain, so on June 20th, three days before the scheduled date, she is ready to postpone the celebration if adverse weather is forecast. Sophie knows that in recent years, it has rained for 2 days out of 30 in the month of June. She also knows that the weather service correctly predicts rain with a 95% accuracy rate when it actually rains, but also predicts rain when it doesn't rain in the 10% of the cases with a three-day advance forecast. a) If the weather service forecasts rain, what is the probability that it will actually be sunny and Sophie will unnecessarily postpone the party? b) If the weather service forecasts dry weather, what is the probability of the party actually being ruined by rain? Answers: (even with an adverse forecast Sophia can take the risk) (with a dry weather forecast the probability of rain is very very low)

References:

M.P.K. Webb and D. Sidebotham, Bayes' formula: a powerful but counterintuitive tool for medical decision-making, 2020 https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7808025/ A. Etz, Introduction to the Concept of Likelihood and Its Applications, 2017 https://journals.sagepub.com/doi/10.1177/2515245917744314 Wikipedia, Bayes' Theorem, https://en.wikipedia.org/wiki/Bayes%27_theorem