Python demo: Bayes-Odds Updater

Understanding Evidence, Part 0.5

In order to demonstrate how you can update your beliefs using Bayes theorem as we discussed in the last post, I wrote a simple program in Python. Try it here: Bayesian Belief Manager.

First, you have some piece of evidence you want to incorporate into your views. It could be any information-bearing event, but for the sake of simplicity, let’s just consider a clinical trial investigating the effects of ketamine on major depression.

Then you’re asked to list the hypotheses you have about the state of something, e.g. how ketamine affects depression. Or who will win the next US election (“Trump:Warren:Yang:Other”), or how climate change will affect global temperature in Celsius (“>4:4-3:3-2:2-1:1-0:<0”). The requirement is just that your hypotheses exhaust all the possibilities for that something—which you can always do by including “other” as a hypothesis.

Now list your prior odds for the respective hypotheses. E.g. “1:4:2” in the example means that you think “no effect” is twice as likely as “negative effect” and four times as likely as “positive effect”.

Now for evaluating the evidence: list your likelihood ratios for each of the hypotheses. “2:1:0.5” in the example means that you think the evidence provides twice as much evidence in support of the “positive effect” hypothesis as it does for the “no effect” hypothesis, and four times as much as for “negative effect”. This concept is the key to understanding Bayesian reasoning and is explained in more detail in the previous post.

And then for the results:

Conveniently summed up as probabilities in the end. And that’s how Bayes works. Hope this helps!

One thought on “Python demo: Bayes-Odds Updater

Leave a comment