brand banner

Updated

Bayesian Inference: Alice’s Coin, Likelihood, MLE, and MAP

One hidden coin connects conditional independence, Bayesian updating, prediction, Naive Bayes, and maximum-likelihood estimation.

The central distinction is between how probable an observation is under a hypothesis and how probable the hypothesis is after an observation. Alice’s coin example makes that distinction concrete. It also separates updating a belief, predicting an outcome, fitting a parameter, and choosing a class.

Alice picks one coin, once

Alice has a fair coin and a loaded coin whose probability of heads is 𝑝, where 12<𝑝≤1. She chooses each coin with probability 12, then flips that same coin twice. Define the events:

Once we know which coin she picked, the probability of the second head is straightforward:

𝑃(𝐵∣𝐹)=12,𝑃(𝐵∣𝐿)=𝑝.

The first and second flips are independent given the coin’s identity. For example, 𝑃(𝐵∣𝐴∩𝐿)=𝑝: learning that the first flip was heads does not change the loaded coin’s bias.

Why the first and second flips have the same marginal probability

If we do not know which coin Alice picked and have not observed either flip, we average over the two possible coin choices:

𝑃(𝐴)=𝑃(𝐴∣𝐹)𝑃(𝐹)+𝑃(𝐴∣𝐿)𝑃(𝐿)=14+𝑝2.

Exactly the same reasoning applies to the second flip:

𝑃(𝐵)=𝑃(𝐵∣𝐹)𝑃(𝐹)+𝑃(𝐵∣𝐿)𝑃(𝐿)=14+𝑝2.

Thus 𝑃(𝐴)=𝑃(𝐵). This equality is what “by symmetry” means here: before observing results, neither flip position has an advantage.

We are averaging over the single choice made at the start. This does not mean Alice chooses another coin before the second flip. If we know the selected coin, we use the corresponding conditional probability instead.

Equal probabilities do not mean independent outcomes

For two heads, each possible coin produces a different probability:

𝑃(𝐴∩𝐵∣𝐹)=14,𝑃(𝐴∩𝐵∣𝐿)=𝑝2.

Average over the original coin choice again:

𝑃(𝐴∩𝐵)=12⋅14+12⋅𝑝2=18+𝑝22.

For 𝑝=0.9,

𝑃(𝐴)=𝑃(𝐵)=0.70,𝑃(𝐴∩𝐵)=0.53,

but 𝑃(𝐴)𝑃(𝐵)=0.49. Because 0.53≠0.49, the two events are not independent when the coin is unknown.

There is one shared hidden choice behind both flips. Seeing a head gives us information about that choice, which helps us predict the other flip. The coin does not change; our information changes.

Prior, likelihood, evidence, and posterior

Suppose the first flip is heads. We now want to know which coin Alice picked. Bayes’ theorem reverses the direction of conditioning:

𝑃(𝐿∣𝐴)=𝑃(𝐴∣𝐿)𝑃(𝐿)𝑃(𝐴).

The four quantities have different jobs:

A prior is not necessarily an uninformed guess. Here it comes from knowing that Alice chooses each coin with equal probability. “Prior” means before considering this evidence, not before knowing anything at all.

For 𝑝=0.9,

𝑃(𝐿∣𝐴)=0.9⋅0.50.70=914≈0.643,𝑃(𝐹∣𝐴)=0.5⋅0.50.70=514≈0.357.

A head raises our probability for the loaded coin from 50% to about 64.3%, because a head is more likely with that coin. This revision is Bayesian updating. If more observations arrive, the current posterior can serve as the prior for the next update, using the likelihood of the new observations given the hypothesis and any relevant previous data.

A likelihood assumes a hypothesis, not a prior

A useful phrasing is:

The likelihood tells us how probable the observed evidence would be if a particular hypothesis were true.

We do not need a prior to calculate 𝑃(𝐴∣𝐿)=0.9. We need the prior when turning that likelihood into the posterior 𝑃(𝐿∣𝐴).

For general observed data 𝐷 and a candidate hypothesis ℎ, the likelihood function is

ℒ︀(ℎ)=𝑃(𝐷∣ℎ).

Hold the observations 𝐷 fixed and vary ℎ. The likelihood compares how well different hypotheses account for those same observations. It is not a probability distribution over hypotheses: its values need not sum to one across the candidates.

In particular, 𝑃(𝐴∣𝐿)=0.9 does not mean that the probability Alice picked the loaded coin is 0.9. That question asks for 𝑃(𝐿∣𝐴).

Predicting the second flip after a head

Once we have updated the probabilities of the two coins, use those new weights to predict the next outcome:

𝑃(𝐵∣𝐴)=𝑃(𝐵∣𝐴∩𝐿)𝑃(𝐿∣𝐴)+𝑃(𝐵∣𝐴∩𝐹)𝑃(𝐹∣𝐴).

Given the coin, its flips are independent. Therefore,

𝑃(𝐵∣𝐴)=𝑝𝑃(𝐿∣𝐴)+12𝑃(𝐹∣𝐴).

Read this as two cases: the loaded coin gives a head with probability 𝑝; the fair coin gives a head with probability 12. Weight each case by how likely that coin is after the first head.

For 𝑝=0.9,

𝑃(𝐵∣𝐴)=0.9⋅914+0.5⋅514=5370≈0.757.

This agrees with the conditional-probability calculation:

𝑃(𝐵∣𝐴)=𝑃(𝐴∩𝐵)𝑃(𝐴)=0.530.70.

Using the posterior to predict a new observation is posterior prediction. It is a different step from updating the coin probabilities themselves.

If the question instead asks for tails on the second flip, use 1−𝑝:

𝑃(𝐵𝑐∣𝐴)=(1−𝑝)𝑃(𝐿∣𝐴)+12𝑃(𝐹∣𝐴).

Here 𝐵𝑐 means “not 𝐵.” The fair-coin term remains 12 because either side of a fair coin has that probability.

Maximum likelihood: what are we maximizing?

Maximum likelihood holds the observed data fixed and chooses the hypothesis or parameter value that makes those observations most probable:

ℎ̂ML=arg maxℎ𝑃(𝐷∣ℎ).

The expression arg max returns the candidate that wins, not the value of the winning likelihood.

If the data is one head and the only candidates are the fair coin and the loaded coin with 𝑝=0.9, maximum likelihood chooses the loaded coin:

𝑃(𝐴∣𝐿)=0.9>𝑃(𝐴∣𝐹)=0.5.

This choice does not use the prior and does not give a posterior probability. It also does not claim that the chosen coin certainly produced the head.

Why a sample proportion is an MLE

Now consider a parameter-estimation problem. Let 𝜃 be the unknown probability that a spam email contains “prize.” We observe 100 independently sampled spam emails: 80 contain the word and 20 do not.

Writing 𝜃̂=80100 only states an estimate. To explain why it is maximum likelihood, we must show what is being maximized.

Model each email’s word-presence indicator as an independent Bernoulli observation with probability 𝜃. Let 𝐷 be the observed sequence of 80 presences and 20 absences. All 100 emails are already known to be spam. The likelihood function is

ℒ︀(𝜃)=𝑃(𝐷∣𝜃)=𝜃80(1−𝜃)20,0≤𝜃≤1.

This is still the probability of evidence under an assumed hypothesis. Here, the hypothesis is a proposed value of 𝜃. For example:

The connection to Alice’s coin is direct. In 𝑃(𝐴∣𝐿), the evidence is a head and the hypothesis is “Alice picked the loaded coin.” In 𝑃(𝐷∣𝜃), the evidence is the training sequence and the hypothesis specifies the word-presence probability. Both ask: How probable is this evidence under this hypothesis?

The calligraphic ℒ︀ simply names the likelihood function. Writing ℒ︀(𝜃) emphasizes that we keep the evidence fixed and vary the candidate 𝜃. It is not 𝑃(𝜃∣𝐷), which would describe a posterior over the unknown parameter after specifying a prior.

Nor are we trying to make “prize” as probable as possible. Setting 𝜃=1 would make the 20 observed absences impossible and give ℒ︀(1)=0. We must make the whole observed sequence probable, including both presences and absences.

The 80 and 20 are fixed observations. We vary 𝜃, balancing the probability of the observed presences against the observed absences. Maximizing the logarithm gives the same result because the logarithm is strictly increasing:

ℓ(𝜃)=80log(𝜃)+20log(1−𝜃).

On 0<𝜃<1, set the derivative to zero:

ℓ′(𝜃)=80𝜃−201−𝜃=0⇒𝜃̂MLE=80100=0.8.

This is the unique maximum: the second derivative is negative throughout the interior, and the likelihood is zero at both endpoints for these data.

If we record only the count 80 rather than the ordered sequence, the likelihood also contains the binomial coefficient (10080). That factor does not depend on 𝜃, so it does not change the maximizer.

Keep these three objects separate:

The sample proportion is a shortcut formula derived from maximization. The number 0.8 is the estimated parameter, not the likelihood of the 100-email dataset.

MAP: choose the highest posterior

Maximum a posteriori (MAP) chooses the hypothesis with the greatest posterior probability:

ℎ̂MAP=arg maxℎ𝑃(ℎ∣𝐷)=arg maxℎ𝑃(𝐷∣ℎ)𝑃(ℎ).

The denominator 𝑃(𝐷) in Bayes’ theorem is the same for every candidate and is positive for the evidence under consideration. It therefore does not affect which candidate wins.

The distinction is:

For a contrasting example, change Alice’s selection rule: she now picks the loaded coin only 10% of the time. Keep 𝑝=0.9 and observe one head. The unnormalized posterior scores are

loaded:0.9⋅0.1=0.09,fair:0.5⋅0.9=0.45.

Maximum likelihood still chooses loaded, since 0.9>0.5. MAP chooses fair, since 0.45>0.09. Normalizing gives posterior probabilities 16 for loaded and 56 for fair.

A head favours the loaded coin relative to its prior probability, but not enough to make it the more probable coin overall. With equal priors across the candidates, MAP and maximum likelihood make the same choice.

MAP selects one hypothesis. It is not the same as keeping the full posterior. In Alice’s prediction problem, we retained both possible coins and averaged their predictions rather than simply using the MAP coin.

Naive Bayes is a classifier, not an estimation method

For classification, a hypothesis is a candidate class 𝑐, such as spam or not spam. The observed evidence is a vector of features 𝑥=(𝑥1,…,𝑥𝑛), such as whether particular words are present. Bayes’ theorem gives

𝑃(𝑐∣𝑥)=𝑃(𝑥∣𝑐)𝑃(𝑐)𝑃(𝑥).

Naive Bayes assumes that the features are mutually independent given the class. That assumption supplies the factorization

𝑃(𝑥∣𝑐)=∏𝑖=1𝑛𝑃(𝑥𝑖∣𝑐).

It does not require the features to be independent when the class is unknown. This is the same kind of distinction as Alice’s flips: independent once we know the hidden category, but potentially dependent when we do not.

The usual Naive Bayes decision rule chooses the class with the highest posterior:

𝑐̂=arg max𝑐𝑃(𝑐)∏𝑖=1𝑛𝑃(𝑥𝑖∣𝑐).

This is a MAP class decision, because it includes the class prior. There is no need to compute 𝑃(𝑥) just to choose a class; it is common to all candidates. To report normalized class probabilities, we do need to normalize the scores.

Where MLE fits into Naive Bayes

Before classifying new examples, we must estimate the model’s probabilities from labelled training data. MLE is one way to do that. In a Bernoulli Naive Bayes model, the 80-out-of-100 calculation above estimates a word-presence probability within the spam class. Class proportions can also estimate the class priors.

These are two different stages:

  1. Training: estimate parameters from the training data, perhaps using MLE.
  2. Prediction: use those parameters and the class priors to make a MAP decision for a new example.

A MAP class decision does not imply that the parameters themselves were estimated by MAP. Likewise, a class prior can be estimated from training data; it is “prior” relative to the new example’s features.

In practice, word probabilities are often smoothed to avoid assigning zero probability to an entire example because one feature was unseen in a class. Smoothed estimates generally differ from the raw MLE proportions.

Naive Bayes specifies a model and classification rule. MLE specifies how to fit parameters. MAP specifies how to select a posterior maximizer. They are related ideas, not interchangeable names.

The formal foundation: a probability space

A probability space is a three-tuple

(Ω,ℱ︀,𝑃).

Briefly, its components are:

For Alice’s experiment, a complete outcome records both the one coin choice and the two flip results:

Ω={𝐹,𝐿}×{𝐻,𝑇}×{𝐻,𝑇}.

There are eight possible outcomes, such as (𝐿,𝐻,𝑇). Here 𝐹 and 𝐿 inside the tuples label the coin; the corresponding events are the sets of outcomes with that coin label. Because this space is finite, we can use all subsets as events: ℱ︀=2Ω.

Each fair-coin outcome has probability 18. The loaded-coin outcomes have probabilities

𝑃({(𝐿,𝐻,𝐻)})=12𝑝2,𝑃({(𝐿,𝐻,𝑇)})=12𝑝(1−𝑝),𝑃({(𝐿,𝑇,𝐻)})=12(1−𝑝)𝑝,𝑃({(𝐿,𝑇,𝑇)})=12(1−𝑝)2.

The factor 12 is the probability of selecting that coin. Event probabilities are sums of the probabilities of their member outcomes. For example, 𝐴 consists of all outcomes whose first flip is 𝐻.

Finally, conditional probability is defined, for 𝑃(𝐴)>0, by

𝑃(𝐵∣𝐴)=𝑃(𝐴∩𝐵)𝑃(𝐴).

Conditioning restricts attention to outcomes consistent with 𝐴 and rescales their probabilities to total one. Bayesian updating uses this same definition to revise probabilities of hypotheses. It changes the probabilities we assign after learning evidence, not the coin Alice already selected.

A compact map of the ideas


© 2026 James Yap

Personal Website and Knowledge Base