WOLFRAM NOTEBOOK

WOLFRAM|DEMONSTRATIONS PROJECT

Bayes's Theorem and Inverse Probability

sensitivity P(D|S)
0.8
specificity P(¬D|¬S)
0.7
base rate P(S)
0.2
This Demonstration allows you to explore the quantitative relationship between two conditional probability assessments,
P(S|D)
and
P(D|S)
, one the inverse of the other, where
P
stands for probability,
D
for a proposition about a "diagnostic signal", and
S
for a proposition about a "state" variable of interest. Typically, the relationship between these inverse probabilities is understood through Bayes's theorem:
P(S|D)=
P(D|S)
P(D|S)P(S)+P(D|¬S)(1-P(S))
P(S)
.
You can vary (1) the red point,
P(D|S)
, the sensitivity of the diagnostic test; (2) the blue point,
P(D|¬S)=1-P(¬D|¬S)
, where
P(¬D|¬S)
is the specificity of the diagnostic test; and (3) the purple point,
P(S)
, the base rate of the state. In this notation
¬S
and
¬D
are symbols for the negations of propositions
S
and
D
, read as "not
S
" and "not
D
".
The Demonstration also illustrates Bayes's theorem. Bayes's theorem compares an unconditional probability for the state,
P(S)
, also called a prior probability, with a conditional probability
P(S|D)
, commonly called a posterior probability. The basic idea here is simple enough: if a signal
D
is more likely given state
S
than it is on average, that is,
P(D|S)>P(D)
, then the posterior probability of the state having seen signal
D
should exceed the prior probability for the state, that is,
P(S|D)>P(S)
, and vice versa if the signal is less likely given the state. This is logically evident from the expression for Bayes's theorem since the weighted average in the denominator of the right-hand side is in fact
P(D)
. This is clear in the graphic by focusing on the horizontal difference between the blue dot and the vertical line through the purple dot as you vary the underlying parameters specified in the sliders.
Keeping simultaneous track of all of the conditional and unconditional probabilities used in inverse probability reasoning is difficult, especially so when one or more of the probabilities is varying. The red and blue dotted lines in the animation are designed to ease that cognitive load, using the idea of weighted averages as a "constraint" on one's thinking about probabilities of states and signals. For example, when the base rate or prior probability
P(S)
is varied, while
P(D|S)
and
P(D|¬S)
remain constant,
P(S)
must remain a weighted average of the two inverse conditional probabilities
P(S|D)
and
P(S|¬D)
, even though the weights
{P(D),1-P(D)}
and the inverse conditional probabilities used in determining this average will all be changing as
P(S)
changes! This particular "weighted average" constraint on
P(S)
is illustrated by the blue dotted line. Symmetrically, the red dotted line shows another constraint, all possible weighted averages
P(D)
of the two endpoints
P(D|S)
and
P(D|¬S)
, with varying weights
{P(S),1-P(S)}
. The key point here is that the two constraints are NOT independent. First, the intersection of the two constraints must occur precisely at the unconditional probabilities
P(S),P(D)
. And second, given the red dotted line, that is, given the specification of the sensitivity and specificity of the test via the parameters in the animation, and given the base rate, also specified parametrically in the animation, the blue dotted line is fully determined. The endpoints of the blue dotted line, the two inverse conditional probabilities
P(D|S)
and
P(D|¬S)
, are especially interesting, since it is the difference between them that really indicates how "informative" the diagnostic signal is for the state. It is a worthwhile exercise to use the Demonstration to observe how uninformative a good (i.e., sensitive and specific) diagnostic test can be for very high or very low values of the base rate
P(S)
.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.