UPDATE 2015-02-16: I’ve added a conceptual explanation of this code here.
Here’s a quick script that you can use (e.g., with a bash “alias” file, which sets shortcuts for the Unix-style command line) for making decisions with Bayes. It’s based off of Nate Silver’s version of Bayes’ Theorem. It can be run with
# The above line just tells the interpreter that this is a python script.
# Jacob Levernier, 2013
# This code is released CC0 (https://creativecommons.org/publicdomain/zero/1.0/) (Public Domain)
# THIS APPLIES BAYES' THEOREM (AS PRINTED ON P. 247 FF. OF NATE SILVER'S BOOK /THE SIGNAL AND THE NOISE/):
print "BAYES THEOREM:"
# (See https://en.wikibooks.org/wiki/Python_Programming/Input_and_output and http://docs.python.org/2/library/functions.html#input)
x=float(input('Make an estimation: How likely (out of 1.00) would you have estimated it would be for your hypothesis to be correct, before seeing this new information (The "prior")? '))
y=float(input('How likely (out of 1.00) do you think it is to see these results if your hypothesized explanation is correct? '))
z=float(input('How likely (out of 1.00) do you think it is to see these results if your hypothesized explanation is NOT correct? '))
print "The revised estimate of how likely (out of 1.00) it is to see these results if your hypothesis is correct, given current circumstances, is",posteriorProbability