Bayes' theorem Created 2026-09-24 Updated 2026-10-14
For a finite measurable partition with positive probabilities, and an event of positive probability,
Its beauty is that a model predicting observations from a hidden state can also describe uncertainty about the state after an observation. Each numerator is a joint probability; the denominator, supplied by the law of total probability, makes the answers sum to one. This is a direct consequence of conditional probability, rather than an extra axiom.
Select the coin from law of total probability once, then toss that same coin repeatedly, with conditionally independent tosses given its identity. Let denote the -head coin, initially of prior probability . After one head , its posterior probability is
The likelihood of a head is larger under , but remains less likely than the other coin because its prior probability was smaller. A large likelihood for an observation does not itself imply a large posterior probability for the hypothesis.
After an ordered sequence containing heads and tails, its likelihood ratio between the two coins is . Bayes' theorem therefore gives posterior odds
Each head multiplies the odds by and each tail by . Three heads give posterior probability , still below one half; four give , above one half. The finite-model update and the distinction between prior probability, likelihood and posterior probability are set out in MIT 18.05, Reading 11: Bayesian Updating with Discrete Priors.
Figure 1.
Updating uncertainty about one selected coin after repeated observations
. Details.
The hidden selection also creates dependence. Each toss has marginal head probability , but two heads have joint probability , greater than . Their indicator covariance is . Seeing a head makes the head-favoring coin more likely, so it also raises the chance of a future head. This is covariance induced by a shared latent variable, despite conditional independence of the tosses given the coin.
Historically, Thomas Bayes's essay on an unknown success probability appeared in 1763 after his death, communicated by Richard Price. Its opening problem asks how observed successes and failures constrain that unknown probability; Price's introductory letter explains the connection to reasoning from experience. That is a more substantial inference problem than simply rearranging today's elementary identity. [ref]
Conditional independence Created 2026-09-24 Updated 2026-10-14
Random variables and are conditionally independent given when, for every pair of Borel sets , the following identity holds almost surely:
Here conditional probabilities are conditional expectations of the corresponding indicator random variables given the sigma-algebra generated by . This defines the condition even when . In terms of regular conditional distributions, the conditional joint law is the product of the conditional marginal distributions for almost every conditioning value.
For discrete random variables, at every with , the condition becomes
Where , this is equivalent to . Once is known, observing provides no further information about .[ref]
For a worked example, suppose a latent variable chooses between two environments with . Given , take to be independent and identically distributed with a Bernoulli distribution of parameter , where and . Think of two separate trials run under the same quiet or active environment. Their conditional joint probability mass functions, with rows and columns , are
Each is exactly the product of its own conditional marginal distributions: for , and for . Thus are conditionally independent given .
If the environment is unobserved, the law of total probability averages the two tables:
Both unconditional marginal distributions are fair, but . The law of total expectation gives
Figure 1.
An unobserved shared environment creates statistical dependence between conditionally independent trials
. The first two tables show independent Bernoulli trials at conditional success probabilities and . Averaging them with equal weights gives the third table. The fourth table is the product of the resulting unconditional marginal distributions, which differs from the actual joint table. These are stipulated model probabilities, not observed frequencies. Details.
Observing makes the active environment more plausible, so it raises to . Knowing the actual environment removes this source of statistical dependence. The covariance induced by a shared latent variable lemma explains the calculation without listing all the outcomes.
This is why conditional independence is useful in statistical modelling: a model can multiply simple conditional laws and then average over a shared latent variable. The resulting observations can remain statistically dependent. Conditional independence graphs organize such information relations; their interpretation as causes requires additional assumptions from causal inference. Conditioning describes the information available to an observer. It does not, by itself, describe what would happen if an experimenter changed a variable.
A time-homogeneous Discrete-time Markov chain is a sequence of random variables indexed by nonnegative integers, with the displayed conditional probabilities. Here is its natural filtration and is a row-stochastic transition matrix. The Markov property removes dependence on earlier observations once is specified; the time-homogeneous Markov property makes independent of .
Consider states (sunny) and (rainy), with the constructed transition matrix
Rows give today's state and columns tomorrow's, in order . These numbers define an illustrative model, with one step interpreted as one day; they are not estimates of real weather. Let . The law of total probability gives the recurrence relation
Subtracting makes the deviation multiply by at each step. Thus
Starting sunny gives , , and ; starting rainy gives and . The two predictions approach the same stationary distribution while retaining a shrinking trace of the initial probability distribution.
Figure 1.
Constructed sunny/rainy transitions and the exact sunny probabilities from three initial distributions.
Details.
An expected hitting time answers a different question. Starting sunny, let . Every day before the first rain remains sunny, so
This geometric distribution has finite expected value. A first-step calculation gives , with , hence days. The same result follows from the geometric series . This is a mean waiting time, not a prediction that rain first occurs exactly five days later.
A probability row vector is a stationary distribution when . The Markov chain is reversible in that law when detailed balance holds: . Multiplying those equations along a finite path gives equal forward and reversed stationary path probabilities.
Let for the input bit of a binary symmetric channel with crossover probability . The law of total probability gives
Consequently its mutual information is
Here specifies the noise and specifies the input bias; they are different choices. At and , the output has , giving and bits. With the same noise and the fair input , the output becomes fair and bits, attaining binary symmetric channel capacity.
Figure 1.
A fair input maximizes retained information through a binary symmetric channel
. The left panel holds the crossover probability fixed and varies . The right panel shows the output probability distributions for with input biases and . More output Shannon entropy helps here because the conditional noise information entropy stays fixed. Details.
For , binary entropy reaches one only at output mass , and the equation forces . Thus the maximizing input is unique in those cases. For , every input produces the same fair output and zero mutual information, so every input bias is optimal and none transmits information. A fixed input or also carries zero mutual information for every : noise can make its output unpredictable without creating an unknown message to recover.
Generate a finite mixture model by drawing a categorical variable with , then drawing from the mixture component . The indicator random variables satisfy : exactly one mixture component generates each draw. The joint probability distribution obeys , and the law of total probability gives the mixture distribution after summing out .[ref]
For independent draws from this statistical model, draw a fresh for each . Drawing one shared latent variable for an entire collection is a different joint probability distribution: its individual marginal distributions can match the same mixture distribution while its observations are dependent.
Use the equally likely release prior, and write for the probability that the guard names B when A is released. If B is released the guard cannot name B; if C is released the guard must name B. The law of total probability therefore gives
A remains jailed and B is named precisely when C is released. Its probability is , so the conditional probability is
In (a) unbiased naming has , giving : the guard's claim is false and A's chances have not improved. In (b) preferentially naming B has , giving : that naming rule makes the claim correct. In (c) preferentially naming C has , giving : naming B then reveals that C is the released person, so A certainly remains.
This is the three prisoners problem. The observed name includes information about how the guard selects a name; it is not merely the event that B remains. With general release priors , the same calculation gives , making explicit where the equal-prior convention enters.
For , the conditional probability is . Since the events partition the sample space, their intersections with are disjoint and exhaust . The law of total probability therefore gives . Substituting this and into the definition proves Bayes' theorem:
The denominator is positive by the given hypothesis on .
Every urn contains balls. Let be its number of blue balls; choosing an urn uniformly makes uniform on . Conditional on that urn, the probability of a blue first draw is , so the law of total probability gives
Drawing twice without replacement requires . Given , the probability that both draws are blue is , and hence
Taking the ratio defining conditional probability gives the second requested probability
Although a blue first draw removes a blue ball from its urn, it also makes an urn rich in blue balls more likely. Averaging with this changed conditional distribution is essential.
Condition on the claim count. The empty random sum of independent claims is zero, and independence gives . Therefore the random-sum transform identity is
wherever the composition is finite. This follows directly from the law of total expectation, rather than replacing the random count by its mean.
Put . For the specified negative binomial distribution, the negative binomial series gives . A rate- exponential distribution has moment-generating function . Hence
The last expression is exactly the moment-generating function of a compound binomial distribution with independent count and severities
The moment-generating function exists in a neighborhood of zero, so its uniqueness identifies the distributions. In particular, the new claim sizes have mean , not , and both aggregate distributions have an atom at zero. This is the negative-binomial sum of exponential claims representation with the severity rate explicitly retained.
Conditional on , the aggregate has Erlang distribution with density on . Repeated integration by parts of its tail gives
Indeed, after substituting , the integral reduces recursively to the corresponding integral with exponent , terminating at . Applying the law of total probability yields the original infinite mixture distribution tail
Applying the same argument to the compound binomial distribution gives instead the finite Erlang-mixture tail for a negative-binomial exponential aggregate:
The two tails are equal. The binomial representation replaces an infinite sum by a finite exact calculation, eliminating the need to choose a claim-count truncation and control its omitted tail. The inner sums can be evaluated recursively, using for their exponential-weighted terms.
Use the intended model of independent random variables with exponential distributions of rates . For , independence gives the survival function
Thus
The variance is , obtained from the standard first two exponential moments, and .
For these competing exponential clocks, ties have probability zero. Integrating over Alice's firing time gives
Let denote the event that the next shot hits, and use the stated success probability as . Bill's corresponding conditional success probability is one. The law of total probability gives
The Bayes' theorem therefore yields
The printed assumptions specify the two marginal exponential distributions but do not explicitly specify their independence. The answers above require that extra assumption; marginals alone do not determine the race. For a concrete counterexample, take one and set , . These have the required marginals, but ; if , Alice always fires first and . Thus the independence qualification changes actual answers, rather than merely their derivation.
Treat as the entire phase-known genotype of individual at the genetic loci being studied, and let denote the nonfounders. Assume unrelated pedigree founders have independent genotype priors, each nonfounder's genotype depends only on its parents' genotypes, and the observed phenotypes are conditionally independent given the genotypes. These are the standard assumptions behind the pedigree likelihood; shared environmental effects or related pedigree founders would require additional factors.
The directed ancestry graph is acyclic, even when there is inbreeding. Order individuals with parents preceding offspring and apply the chain rule for probabilities. The parental conditional independence assumption gives
Conditional phenotype independence gives . Multiplying these two expressions and summing over every possible latent genotype configuration proves
This is the law of total probability, not a claim that relatives have independent unconditional genotypes.
There are two disjoint ways to make an error: an individual from class one falls outside , or an individual from class two falls inside . The law of total probability gives
Since integrates to one, this also equals
This form isolates the only term changed by choosing the decision region.
The law of total probability and the definition of conditional probability give Bayes' theorem:
The denominator is positive because .
For the observed cargo, set , , . The binomial likelihood under origin is
Equal prior probabilities and Bayes' theorem make the posterior proportional to these likelihoods. The binomial coefficient cancels in the likelihood ratios:
Thus and , giving
Even the permitted approximation gives log ratios about and , which already show overwhelming posterior preference for B. The exact logarithms are preferable because multiplication by magnifies the approximation error. An observed contamination fraction halfway between two hypothesized rates does not give equal likelihoods: the binomial distribution assigns asymmetric probabilities to those deviations, especially at this large sample size.
The events are pairwise disjoint and their union is . Finite additivity and the definition of conditional probability therefore give the law of total probability:
For the birthday problem, let mean that all birthdays differ. For , sequential conditioning on previous distinct birthdays and independence of random variables give
Here each factor uses the stated bound . For , , so
For a match is certain by the pigeonhole principle. The threshold from the exponential bound is , so suffices.
By the definition of conditional probability,
Since the form a disjoint partition of the sample space, the law of total probability gives . Substitution proves Bayes' theorem in the required form:
The hypotheses make the denominator positive and each conditioning probability well defined.
Let denote the mattress count and the event of undisturbed sleep. Use the intended model in which the presence of the pea is independent of , with probability , and without a pea sleep is undisturbed. Conditioning on gives
The law of total probability and the equal prior probabilities give
By Bayes' theorem, the posterior probabilities of given are respectively . Therefore the conditional expectation is
Undisturbed sleep shifts the posterior toward larger mattress counts because those counts make the observation more likely.
For events with , the conditional probability is . Applying the definition in both orders gives Bayes' theorem:
Conditionally on , independent fair tosses give a binomial distribution for the head count, so . The joint probability mass function is consequently
Use the law of total probability and the differentiated geometric series, , to obtain . The posterior coin count after exactly one head is therefore
These probabilities sum to one by the same series identity. The conditioning weights possible coin counts by their likelihood of producing exactly one head.
A frailty model uses an unobserved nonnegative random hazard multiplier to represent variation in individual risk. In a proportional frailty model, conditional on the cumulative hazard function is , giving survivor . Averaging over the frailty random variable by the law of total probability yields
the Laplace transform of the frailty distribution evaluated at the baseline integrated hazard. This also applies to atoms by integration against the probability measure; the printed Dirac expression is not an ordinary continuous density.
In the given two-atom case, the Dirac delta function notation assigns probabilities and to and . These have mean one, fixing the frailty scale relative to the baseline hazard. With , the two conditional integrated hazards are and . Therefore
The frailty distribution among survivors shifts toward the smaller multiplier over time, reproducing the declining population hazard and limit one without changing either individual's constant conditional hazard.
By the partition and the law of total probability, . Also . Combining these identities proves Bayes' theorem:
The assumed positive probabilities make the conditional expressions well defined.