Bayesian Calculator

This is a simple applet for running Bayesian equations:

Enter values as probabilities in algebraic notation (e.g. for 60% type .6, i.e. the percentage, 60, divided by 100). The above applet is published by Curtis Brown through Trinity University. To understand what this calculator does you should become acquainted with the actual equation it's solving for you. Bayes' Theorem (long form) is:

P(T|E.B) = (P(T|B) x P(E|T.B)) / [(P(T|B) x P(E|T.B)) + (P(~T|B) x P(E|~T.B))]

In which there are four variables that determine the probability that a hypothesis is true. You need only three values. T is the hypothesis under test. E is the evidence T is expected to explain. B is all your current background knowledge. You should always assume all three values are conditional on background knowledge. So in the above calculator P(T) is actually P(T|B), etc. The applet rounds all results to four decimal places but can accept longer inputs.

P(T) is the prior probability that T is true. The fourth variable in Bayes' Theorem, P(~T), the prior probability that T is false, is always 1 - P(T) so it doesn't have to be entered (the calculator already figures it in). The other two variables are the probability that the evidence would exist if T is true, which is P(E|T), and the probability that the evidence would exist if T is false, which is P(E|~T). The result is the probability that T is true given that evidence.

I would like to have an applet that allows you to enter the conclusion you want and two of the three values, to then see what the third value would have to be to get that conclusion. I'd also like an applet that allows you to enter maximums and minimums for each variable (making a range of probabilities for each) to show the maximum and mininum result. I would also like to have an applet that allows you to run the equation for three competing hypotheses, which is as follows (note that in the following P(T1), P(T2), and P(T3) must always sum to 1):

P(T1|E.B) =
(P(T1|B) x P(E|T1.B)) /
[(P(T1|B) x P(E|T1.B)) + (P(T2|B) x P(E|T2.B)) + (P(T3|B) x P(E|T3.B))]

If anyone writes applets and is keen to help, please contact me. Or to learn more about Bayes' Theorem see my PDF tutorial. But in general there are six general rules you can apply to use the calculator effectively:

Rule 1: Ask yourself (honestly) how frequently is the kind of hypothesis you're proposing true in other cases? That's the prior probability. Not exactly, but usually close enough. To be more exact, it will conform to Laplace's Law of Succession: because the present case is always as yet undecided, the prior probability will equal (s+1)/(n+2), where s is the number of times your kind of hypothesis has turned out to be true, and n is the number of prior cases altogether, so that given ten prior cases in which your hypothesis is never true, the prior would be (0+1)/(10+2) = 1/12 = 0.083 (or 8.3%), and given ten prior cases in which your hypothesis has always been true, the prior would be (10+1)/(10+2) = 11/12 = 0.917 (or 91.7%), etc. Unless you can present decisive evidence that the value should differ from Laplace's Law of Succession.

Rule 2: Ask yourself (honestly) how likely is it that the evidence would look in any way different if T is true? That's P(~E|T) and P(E|T) = 1 - P(~E|T).

Rule 3: Ask yourself (honestly) how likely is it that the evidence would look in any way different if T is false? That's P(~E|~T) and P(E|~T) = 1 - P(~E|~T).

Rule 4: In answering the previous two questions, irrelevant differences should be ignored, e.g. T might predict that there will be a piece of fruit on your doorstep, in which case an apple on your doorstep confirms T, and yet there could have been a banana, etc., but the fact that the evidence could have been different in that way is irrelevant to T, and therefore P(E|T) is still in this case 100% if an apple is present, even though, strictly speaking, the probability that it would be an apple rather than some other fruit is not 100% (this is mathematically allowed because the contingency of what kind of fruit will be there has a probability independent of T that actually cancels out in the equation).

Rule 5: Argue a fortiori. You might not know what the exact probability is for any of the three variables, but you will usually know it can't possibly be higher than some value, nor lower than some value. If between those two values you use the value that goes the most against your hypothesis, then you can be sure the probability your hypothesis is true will be even higher than the result calculated (or certainly no lower). Conversely, if you use the value that goes the most in favor of your hypothesis, then you can be sure the probability your hypothesis is true can't be higher than the result calculated (and is probably lower).

Rule 6: The probability of the evidence E if the hypothesis T is false is not the probability of E in the absence of any causes whatever. That is, it is not the probability of E resulting from pure random chance. Rather, P(E|~T) is the probability that the evidence would exist if in fact caused by something else. When there is only one other cause with any significant prior probability, then P(E|~T) ≅ P(E|T*), where T* is a specific hypothesis other than T (when P(T*) ≅ P(~T)). If there are many viable hypotheses, we need an expanded equation (per above), unless P(E|T*) for every viable T* is approximately the same. Otherwise, the only way to use the applet above to complete the expanded equation is to manually calculate P(E|~T), using the following equation:

P(E|~T) = (P(T2) x P(E|T2)) + (P(T3) x P(E|T3)) + (etc.).

If you attempt this, all the prior probabilities (including P(T)), must sum to exactly 1 (because you must divide the total probability space among all possible explanations of E). Finally, of course, if the only viable alternative to T (the only alternative with a non-negligible prior probability) is purely random chance, then P(E|~T) will be the probability of E resulting from pure random chance. But usually there are plausible alternative causes of E.

As an example of applying Rule 1, if the evidence is that your wallet is missing, and you are asking how likely it is that your wallet was stolen, what is the frequency of "your wallet was stolen" the cause of "your wallet is missing"? If your wallet has often gone missing but every time you discovered you had just dropped it or misplaced it, then the frequency of "your wallet was stolen" being true is low, and so must its prior probability be. Unless the conditions are notably different (e.g. lots of things have been stolen around you lately or in that place in particular), in which case you take that into account, too. Analogously, if someone tells you their limbs grew back after having been chopped off, how frequently is "a human's arms grew back after being chopped off" actually the explanation of such evidence (that such a person, with arms and legs intact, would say something like this to you), as opposed to some other explanation being true instead (e.g. "they're crazy," "they're lying," "they're joking," etc.)? The same reasoning applies to asking how frequently a cause like T produces evidence like E (which is the probability that E given T, which is P(E|T)).

In answering questions like this you will often need to estimate hypothetical frequencies, e.g. if your wallet has never gone missing, or done so only once (or you never determined how it went missing) your actual database will be too sparse to estimate an actual frequency of causes, but you can use your background knowledge to hypothesize what a larger database would look like, relying on information about the frequency of you dropping or misplacing things, and of thefts occurring in the area, and the physical properties of your wallet and pocket and what you did that day (which can affect the likelihood of it falling out, etc.). Combining this with a fortiori reasoning will produce reliable results (i.e. the actual probability of T, given all that you currently know).

This page was composed in 2011 by Richard Carrier, Ph.D. It is intended as a helpful resource, and accordingly it will likely be revised, updated, or expanded in future.

Contact   •   Home   •   Support

 

The Official Website of Richard Carrier, Ph.D.
Copyright © 2008 All Rights Reserved