Bayes Theorem in Python
David C. Ullrich
ullrich at math.okstate.edu
Tue May 22 18:55:53 CEST 2001
On Tue, 22 May 2001 14:26:14 +0200, "Alex Martelli"
<aleaxit at yahoo.com> wrote:
>"Ron Stephens" <rdsteph at earthlink.net> wrote in message
>news:3B08F864.CD9EA4FB at earthlink.net...
>> Does anyone know if someone has already coded Bayes theorem into Python?
>
>You mean as in:
>
>def Bayes(P_H, P_E, P_E_given_H):
> P_H_given_E = (P_H * P_E_given_H) / P_E
> return P_H_given_E
That's not a coding of Bayes' theorem in Python, it's a coding
of an application of Bayes' theorem. A coding of Bayes's
theorem would look more like this:
Bayes_Theorem = '''If E and H are events in a probability space
and P(E) > 0 then
P(H|E) = P(H) P(E|H) / P(E).'''
A lot easier to code in Python than in a lot of languages...
>...? I suspect somebody must have already coded one
>multiplication and one division into one Python expression,
>yes, although it's hard to be sure about the variable
>names they may have chosen. Or do you mean something
>completely different...?
David C. Ullrich
***********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)
More information about the Python-list
mailing list