Code covered by the BSD License  

Highlights from
Bayes

Be the first to rate this file! 12 Downloads (last 30 days) File Size: 3.94 KB File ID: #25203

Bayes

by Antonio Trujillo-Ortiz

 

02 Sep 2009 (Updated 04 Sep 2009)

Bayes' theorem: the discrete case.

| Watch this File

File Information
Description

This m-file deals with the Bayes' theorem, as well as with the option of the frequency visualization of a given sample.

Rev. Thomas Bayes (1702-1761), developed a very interesting theorem alter known as Bayes' theorem. The work entitled 'An essay towards solving a Problem in the doctrine of Chances' was published in Philosophical Transactions of the Royal Society of London in 1764 (53: 370-418). It was not by Bayes, but it was communicated posthumously by his friend Richard Price in a letter to John Canton in december 23, 1763.

The complete paper in the original notation can be downloading from:
         http://canoe.ens.fr/~ebrian/s1h-dhsrb/1764-bayes.pdf
Also an excellent transcription of it from:
         http://www.stat.ucla.edu/history/essay.pdf

Bayes' theorem is a solution to a problem of 'inverse probability'. It gives you the actual probability of an event given the measured test probabilities. For example, you can:

-Correct for measurement errors. If you know the real probabilities and the chance of a false positive and false negative, you can correct for measurement errors.

-Relate the actual probability to the measured test probability. Bayes’ theorem lets you relate p(X|Y), the chance that an event X happened given the indicator Y, and p(Y|X), the chance the indicator Y happened given that event X occurred.

The Bayes' equation is:

                    p(Y|X)p(X)
      p(X|Y) = -----------------------------------
                    p(Y|X)p(X) + p(Y|~X)p(~X)

Here, the sign ~ means complement.

Note.- According to Eliezer S. Yudkowsky's web page [http://yudkowsky.net/rational/bayes], one thing that's confusing is about the '|' notation. Reading from left to right, '|' means 'given'; reading from right to left, '|' means 'implies' or 'leads to'. Thus, moving your eyes from left to right, X|Y reads 'X given Y' or 'the probability that an element is X, given that the element is Y'. Moving your eyes from right to left, X|Y reads 'Y implies X or 'the probability that an element containing Y is X'.

Syntax: function x = Bayes(a,b,c,d)
     
Inputs:
a - a priori probability (prior, marginal or actual)
b - First conditional probability, p(Y|X) [option=1]; first interaction probability, p(XY) (true positive) [opion=2] or conditional probability, p(Y|X) [option=3]
c - Second conditional probability, p(Y|~X) [option=1]; second interaction probability, p(X~Y) (false positive) [opion=2] or interecation probability, p(~XY) [option=3]
d - Option = 1(default),2,or 3
- It shows a dialog whether or not you are interested with the frequency visualization of a given sample

Output:
x - chance positive test or positive result (posterior probability)
- frequency visualization of a given sample (optional)

Required Products Statistics Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
02 Sep 2009

It was added an appropriate format to cite this file.

02 Sep 2009

Text was improved.

04 Sep 2009

Text was improved.

Tag Activity for this File
Tag Applied By Date/Time
bayes theorem Antonio Trujillo-Ortiz 02 Sep 2009 12:04:40
bayes Antonio Trujillo-Ortiz 02 Sep 2009 12:04:40
conditional probability Antonio Trujillo-Ortiz 02 Sep 2009 12:04:40
probability Antonio Trujillo-Ortiz 02 Sep 2009 12:04:40

Contact us at files@mathworks.com