Select your font size 
 
about us products & services consulting & support news & events contact us
Discussion of the canonical formula for Bayes Inference.

Deriving Bayes' Theorem - PEI

print this article 
 

You are now in a position to discuss the canonical formula for Bayes inference. The derivation of Bayes formula follows naturally from the definition of conditional probability using the probability format:

P(A | B) = P(A & B) / P(B)

Using some algebra, this equation can be rewritten as:

P(A & B) = P(A | B) P(B)

The same right-hand value can also be computed using A as the conditioning variable:

P(A & B) = P(B | A) P(A)

Given this equivalence, you can write:

P(A | B) P(B) = P(B | A) P(A)

Simplifying, you arrive at Bayes theorem:

P(A | B) = P(B | A) P(A) / P(B)

Notice that this formula for computing a conditional probability is similiar to the original formula with the exception that the joint probability P(A & B) that used to appear in the numerator has been replaced with the equivalent expression P(B | A) P(A).

Computing the full posterior

Bayesian inference is often put forth as a prescriptive framework for hypothesis testing. Using this framework, it is standard to replace P(A | B) with P(H | E) where H stands for hypothesis and E stands for evidence. Bayes inference rule then looks like this:

P(H | E) = P(E | H) P(H) / P(E)

In words, the formula says that the posterior probability of a hypothesis given the evidence P(H | E) is equal to the likelihood of the evidence given the hypothesis P(E | H) multiplied by the prior probability of the hypothesis P(H). You can ignore P(E) as only serving a normalization role (in other words, ensuring the sum of all the cell probabilities is 1.0). You can thus mentally simplify the equation to:

P(H | E) = P(E | H) P(H)

The prior distribution P(H) in this equation can be represented in PHP as an indexed array of probability values (as shown):

var $priors = array();

The $priors array is expected to contain a list of numbers denoting the prior probability of each hypothesis. In the context of medical diagnosis, the $priors array might contain the prevalence rates of each hypothesized disease in the population. Alternatively, the array might contain a medical specialist's best guess as to the prior probability of each disease under consideration given everything they know about each disease and current conditions.

The exact nature of the full posterior probability computation is made clearer by seeing that the posterior and likelihood terms appear in a PHP implementation as two-dimensional arrays (the closest you can currently get to a matrix datatype in PHP).

Listing 3. The posterior and likelihood terms appear in a PHP implementation as 2D arrays
<?php

// $m denotes the number of hypothesis
// $n denotes the number of evidence patterns

$m = 3;
$n = 4;

$priors      = getPriorDistribution();
$likelihoods = getlikelihoodDistribution();
$evidence    = getEvidenceDistribution();

for($e=0; $e < $n; $e++) {
  for ($h=0; $h < $m; $h++) {
    $posterior[$e][$h] = $priors[$h]
       * $likelihoods[$h][$e] / $evidence[$e];
  }
}

?>

For now, ignore the issue of how the $prior, $likelihood, and $evidence distribution values are computed from raw data. You can posit magical get functions to obtain these values. The previous code shows how the values of the posterior probability matrix are computed by looping over the evidence items and the hypothesis alternatives.

The order of the index elements $e and $h in the posterior matrix might be puzzling until you realize that in PHP the evidence key should appear first in the posterior matrix because it is a lookup key. If you access the posterior matrix using an evidence key $e, it will return an array containing the probability of each hypothesis under consideration (such as, +cancer, -cancer) given the particular evidence key you have supplied (like +test). The code above computes the full posterior distribution over all evidence keys. To compute a row of the full posterior distribution for a particular evidence key, you would use this formula:

Figure 2. Formula to compute posterior distribution
Formula to compute posterior distribution



Page:   1  2  3  4  5  6  7  8  9  10  11 Next Page: Medical diagnosis wizard

The content shown in this page was first published by IBM developerWorks and is reprinted with permission from Paul Meagher (www.datavore.com)


Most Recent Website and Regional Updates

 Research Tools
Measure human resource allocation and collect data with the goal of determining patterns that will bring forward actionable insights which may lead to policy changes, saving money and improving quality of service.

 
 Process Evaluation Questions
Questions to help focus discussion about process improvement

 
 Operations Research
Operations Research (frequently called OR), is the methodical study of how to do things better. It is also called Optimization Theory.

 
 Our Role in Operations Optimization
Meet objectives more efficiently by improving operational effectiveness and profitability.

 
 Monte Carlo Method
Short description of the Monte Carlo Method in optimization theory.

 
 Introduction to Markov Process
Introduction to Markov Chains and Markov Processes, with a link to an introductory PDF which provides essential details about Markov analysis, along with helpful examples and exercises.

 
 Windows PC Tech Support Price Calculator
Transparen offers first-class Windows PC and Linux PC tech support services based on a number of factors such as a count of supported desktops.

 
 Remote Technical Support
Remote technical support is provided 24/7 by Transparen's staff, not only for data recovery, but also for proactive maintenance (i.e. detecting problems early, before they become disasters).

 
 Monthly Price for Computer Support Service
Transparen's billing is predictable and affordable. Use our automated price calculator to find the monthly price for our tech support service.

 
 Eco-Friendly Fashions at Affordable Prices

 
 Chef Michael to Host Fall Flavours - Prince Edward Island

 
  Sharon Labchuk: A Force of Nature Leading the Green Party of PEI

 
 The Enviro Church Conservation Project

 
 Carbon credits - Farmers Helping Farmers

 
 21/11/2008: Somali Pirates
Earlier this week, a giant Saudi oil tanker became the largest vessel ever hijacked by pirates operating with near impunity off the coast of Somalia. Today on the Current podcast, we'll have an interview with the head of one of the pirate groups operating in the area.

 
 20/11/2008: Juice Box Investigation
How a tainted juice box led one family on a convoluted quest for answers about their children's health.

 
 19/11/2008: Intimidation by Pharmaceutical Companies
Doctors sometimes discover that the drugs they're prescribing can be more harmful to some of their patients than the diseases they treat. But as CBC Radio health reporter Pauline Dakin tells the Current, some doctors say they've been intimidated by pharmaceutical companies into keeping their suspicions and their research quiet.

 
 18/11/2008: The Ascent of Money: Niall Ferguson
Author Niall Ferguson forecasts our financial future by checking on the planet's moneyed history in his book, "The Ascent of Money: A Financial History of The World".

 
 17/11/2008: Shuja Nawaz on Pakistan
For more than half of its existence as an independent nation, Pakistan has been governed by its military. Author and journalist Shuja Nawaz dissects the Country's military history and provides a perspective on today's political reality.

 
 14/11/2008: Peter C. Newman on Izzy Asper
A bold and brassy Prairie man named Izzy created Canada's third national T.V. network. Now, as CanWest Global sheds jobs and cash, we're stepping back, and remembering the life and times of Israel Asper.

 
 13/11/2008: The Full Interview with Mellissa Fung
Yesterday, Anna Maria spoke with Mellissa Fung, a CBC journalist who was held captive for a month in Afghanistan. This is the only interview Mellissa Fung will do. Today on the Current podcast, their full conversation.

 

Google
 
Web transparen.com

Contact Information

Related Information

 
   
 
E C M | © 2003-2007 Transparen Corp.      

Standardized Services: Data Recovery Service / Creative Services / Premium Web Hosting Services / System Administration Tech Support Services
Recent Projects: Full-Service Mortgage and Financing Company / System to manage flights from Vancouver to Tofino / Photo exchange verification service
Our Vancouver BC Server Proudly Hosts: automated parking and revenue control systems, leafside lane at southlands, cost effective alternative power sources, Higher Grade Learning Centres, pacific forage bag supply, sunburst medical, neosonic design, roger mahler photography - passionate, intriguing, desirable, the connection between east and west, affordable flights to victoria and tofino, low interest mortgage brokers in vancouver, richmond, surrey, toronto, Toronto Calgary and Vancouver IT staffing and talent search
* Alberton * Ascension * Belfast * Borden * Breadalbane * Cavendish * Central Bedeque * Charlottetown * Cornwall * Emerald Junction * Foxley River * Freeland * Georgetown * Hampton * Hebron * Hunter River * Kensington * Knutsford * Miminegash * Montague * Morell * Mt. Stewart * Murray Harbour * Murray River * North Cape * North Rustico * O'Leary * Orwell * Souris * Stanhope * Stratford * Summerside * Tignish * Tyne Valley * Avonlea