Nederlog        

 

12 mei 2007

                                                                 

Beetje meer basic Bayes

 


 

Gisteren schreef ik over Bayes in Basic, en leverde programmacode en programma erbij, voor de liefhebbers.

Hier is een verbeterde versie van programma + programma-code:

  • Bayes.zip - 25,691 bytes

waarin het volgende te vinden is na ontzippen:

  • Bayes.exe - 44,544 bytes

  • Bayes.bas - 7300 bytes

  • Bayes.txt - 3082 bytes

Het is hetzelfde programma als gisteren, maar met een wat minder minimalistisch interface, een heuse H(elp)-functie, en een verbeterde txt, die ik hier afdruk ter instructie:


Bayes.bas illustrates Bayesian reasoning, that is supposed to be somewhat known in this text. One can experiment with the executable by trying out what happens when one does or does not confirm in frequency with the probability of E if T.

Bayes.bas compiles in FreeBasic 0.17.
Bayes.exe is a compilation of Bayes.bas in FreeBasic 0.17.

To run Bayes.exe properly, you need to make the console screen 80*40.

This can be done in Windows by clicking on the console window's icon after it started, opening 'Properties' ('Eigenschappen' in Dutch) and entering the new size for the console if this is smaller than 80*40.

You can also by way of 'Properties' set the background color and the color of the letters, say to darkblue and white.

As you can see in the code in Bayes.bas Basic.exe cannot deal properly with probabilities smaller than 0.0001. (If you know Basic and can compile Bayes.bas you can easily change this.)

Experiments to try with Bayes.exe:

- You can try out all manner of theories, guesses and fantasies
- Try answering in frequency with E|T or E|~T or like neither
- Try large and small differenes between E|T and E|~T
- Test extremes, with small probabilities or probabilities 1 and 0

A useful start is with

T      = The Darwinian theory of evolution holds.
E      = There are fossils found.
E|T   = 0.9
E|~T = 0.1
T      = 0.1

and find some fossils by answering "T" at the prompt.

You can also try

T      = Tony Blair is a good MP.
E      = Tony Blair makes a good decision.
E|T   = 0.8
E|~T = 0.2
T      = 0.5

See how T changes as you enter good and non-good decisions for Blair.

Or this

T      = The Faith according to X (as you please) is true.
E      = There are X-like miracles.
E|T   = 0.9
E|~T = 0.001
T      = 0.9

and enter some non-miracles.

And as final example there is this

T      = This is an infallible theory.
E      = This is a true prediction from an infallible theory.
E|T   = 1
E|~T = 0.5
T      = 0.99

and see what happens in case ~E happens.

And by the way: Since you can enter what you please you can also fix probabilities favouring nonsense if you please, of course. The mathematics remains the same, though, and Bayes.exe calculates the resulting probabilities for you.

Well... you see the possibilities, and can find out the effects of verifying and falsifying the theories and probabilities you entered.

Note that T may be any possible guess whatsoever, E any possible empirical fact whatsoever (that we can verify or falsify), and that E|T, E|~T, and T are up to the user, and are all that is needed.

And you can be sure that your own reasoning, your expectations, your guesses and your beliefs all involve this sort of reasoning, whether consciously or not.

"Probability is the very guide to life!", as Bishop Butler said.

If you want to know more about Bayesian reasoning, check the internet. There is good stuff about it in e.g. the Stanford Encyclopedia of Philosophy.

Have fun!

May 12, 2007
Maarten Maartensz.

Homepage: http://www.maartensz.org


Kortom, op deze site wordt geen moeite gespaard om u te helpen logisch en empirisch te leren redeneren.

En de versie van gisteren van Bayes.zip heb ik vervangen door die van heden. Ik hoop dat het sommigen enige verlichting brengt.


P.S. 14 mei 2007: Er is weer een nieuwe versie van Bayes.zip. Ik hoop dit programma verder te ontwikkelen, en zal dat dan in mijn website elders behandelen, namelijk in de sectie computing.

 

Maarten Maartensz

 

        home - index - top - mail