Human–Machine Convergence
Probability and Bayesian model comparison
Rajesh Ranjan Mahapatra
A first-principles guide to Bayesian model comparison, Bayes factors, marginal likelihood, predictive checking and a rival-first evidence contract with an executable notebook.
© 2026 Rajesh Ranjan Mahapatra. 31 min read
Inference, dynamics and causality
Probability and Bayesian model comparison
Evidence changes rational belief only when rival explanations make explicit predictions before the observation, allowing the data to transfer odds between them rather than decorate a preferred story.
TLDR
- Evidence is contrastive: an observation favours one explanation only relative to what a rival predicted.
- A Bayes factor moves odds: posterior odds equal prior odds multiplied by the rivals’ predictive ratio.
- Flexibility has a predictive cost: marginal likelihood averages fit across a model’s permitted parameter space.
- A winner can still be wrong: model comparison reallocates belief inside a chosen frame, while model checking tests the frame.
- Design evidence rival-first: declare generators, observation channels, dependence, sensitivity and an escape test before acting.
The coin that became less convincing when the alternative became more flexible
A coin lands heads nine times and tails once. Against a fair coin, a model that fixes the chance of heads at 90 per cent predicts that exact sequence almost forty times better. Now replace that alternative with a more permissive story: the coin may have any bias between zero and one. The best-fitting value is still 90 per cent, yet the evidence falls to about nine-to-one.
Nothing about the tosses changed. Only the rival explanation changed. Why should allowing more possibilities make the observed possibility count for less?
The usual intuition treats evidence as a substance carried by the data. Nine heads seem to contain “support for bias”. The hidden assumption is that support belongs to the observation alone. Bayesian model comparison removes that assumption. The data do not award points to a story; they transfer probability mass between stories according to what each put at risk before the data arrived.
The data do not carry a verdict
Imagine two navigation teams studying the same storm track. Team A says the storm followed a warm-water current. Team B says a pressure ridge deflected it. Both can draw a plausible path through the observed points. Looking only at fit, the argument stalls. The useful question is not “Can this story accommodate the track?” It is “Before seeing the track, how much probability did each story place near it?”
That change sounds small, but it alters the object called evidence. A hypothesis that could have explained almost any outcome risks little. A hypothesis that sharply expected one region and was right risks more. Evidence therefore belongs to a relation among an observation, a predictive model and at least one rival. It does not exist as a free-standing glow around a favoured claim.
The odds form reveals the mechanism
Bayes’ rule is often introduced as a formula for reversing a conditional probability. For model comparison, its most revealing form is an update of odds:
Here, M1 and M0 are rival models. The symbol y is the observation. Prior odds state their relative plausibility before this observation. The Bayes factor is the ratio of their predictive probabilities for the observation. Posterior odds are what remain after the transfer. This interpretation is standard in the Bayes-factor literature [Kass & Raftery, 1995].
Suppose the prior odds are one-to-one. If M1 made the data ten times as probable as M0, the posterior odds become ten-to-one. If the prior odds were one-to-nine, the same data produce posterior odds close to one-to-one. The observation did the same comparative work in both cases. It began from a different allocation.
A rare fault alarm
A machine emits an alarm. The alarm triggers 95 per cent of the time when a specific bearing fault is present, but also 5 per cent of the time during ordinary vibration. On a randomly selected operating hour, the fault is present only 1 per cent of the time.
The alarm is nineteen times more likely under the fault model than under ordinary vibration, so the Bayes factor is 19. Yet the prior odds are 1:99. After the alarm, the odds become 19:99, which is a posterior fault probability of about 16 per cent. The alarm is genuine evidence for the fault. It is not enough to make the fault probable.
This is not a paradox. “How much did the evidence favour the fault?” and “How probable is the fault now?” are different questions. The first is answered by the Bayes factor. The second also requires the base rate.
Change the rival, keep the data
Keep the sequence of nine heads and one tail fixed. Compare the fair coin against three alternatives: a coin fixed at 90 per cent heads; a coin with an unknown bias uniformly distributed from zero to one; and a mechanism that makes heads likely only after a warm-up toss.
All three alternatives can fit the final count. They do not predict the same sequence, order or range of possible counts. The evidential force therefore changes when the rival changes. If a claim has no explicit rival generator, “the evidence supports it” is incomplete. The missing information is not rhetorical. It is the denominator of the update.
Likelihood is not posterior probability
Another hidden switch occurs when people move from “the data would be likely if the story were true” to “the story is likely because the data occurred”. The first quantity is p(data | story). The second is P(story | data). They are not interchangeable. The second requires all relevant rivals and their prior weights.
This matters in human and machine intelligence research. A language model may produce a fluent self-report that is likely under a model with access to internal state. The same report may also be likely under a mimic model trained on discourse about introspection. Fluency raises little evidential pressure until a rival predicts something different under an intervention. The Bayesian lesson is not that one must assign a number to consciousness. It is that evidence must be designed around a prediction delta, not around how naturally a preferred story can narrate the result.
A model is a generator, not a label
Calling one explanation “reasoning” and another “memorisation” does not yet create statistical models. Each label must be expanded into a generator that assigns probabilities to observable outcomes. What would the reasoning account predict after a premise is replaced, an intermediate result is hidden or the problem is restated in an unfamiliar notation? What would the memorisation account predict under the same changes? Until those answers exist, the labels organise conversation but cannot carry a likelihood.
The generator also includes the observation channel. A latent fault does not directly produce the number on a dashboard; it changes vibration, the sensor transforms vibration into a signal, software thresholds the signal and an interface displays an alarm. A cognitive mechanism does not directly produce an experimental score; it interacts with instructions, memory limits, response format and scoring. The likelihood belongs to the complete path from mechanism to measurement. Leaving the channel implicit lets analysts attribute sensor, interface or scoring behaviour to the mechanism of interest.
This gives a practical test for a proposed rival. Ask whether it can simulate the data collection process, at least approximately. If it can only explain the observation after the fact, it is a narrative rival rather than a predictive rival. Bayesian model comparison needs the latter. The simulation may be simple, but it must state what could have happened and how often.
flowchart TD A["The coin that became less<br/>convincing when the<br/>alternative became more<br/>flexible"] --> B["The data do not carry a verdict"] B --> C["Flexibility pays through<br/>prediction"] C --> D["The frame can win while<br/>reality loses"] D -. "re-test" .-> A classDef first fill:#0a1424,stroke:#5B5CF6,stroke-width:2px,color:#e6f3ff classDef step fill:#0a1424,stroke:#3f7da0,stroke-width:1px,color:#e6f3ff class A first class B,C,D step
Flexibility pays through prediction
The fixed 90 per cent coin model contains no adjustable parameter. The broad bias model contains a continuum of possible head probabilities. How should a single model make a prediction when it contains many parameter settings?
It averages. Before the tosses, each parameter value predicts possible sequences. The prior distribution says how much of the model’s predictive budget belongs to each value. The marginal likelihood, also called the model evidence, adds those weighted predictions:
The variable θ is a parameter inside model M. The likelihood describes what θ predicts. The prior distributes predictive mass over possible θ values before y is observed.
This integral is the mechanism behind Bayesian complexity control. A flexible model may achieve a high likelihood at one parameter value, but the comparison asks how well the model predicted on average across the parameter values it permitted. Regions that predicted different outcomes consume probability mass. The model wins only if its extra flexibility concentrated enough mass near the observation to repay that cost.
Nine heads under a fixed and a composite alternative
For the exact sequence with nine heads and one tail, a fair coin assigns probability 0.510, about 0.00098. A coin fixed at 90 per cent heads assigns 0.99 × 0.1, about 0.0387. Their ratio is 39.7.
For the broad alternative, let the unknown head probability p have a uniform prior from zero to one. Integrating p9(1−p) over that prior gives 1/110, about 0.00909. Relative to the fair coin, the Bayes factor is 9.31. The broad model still wins, but less decisively.
The assumption doing the work is that the uniform prior genuinely describes the alternative’s pre-data predictive commitment. Change that commitment and the evidence changes. This is not a defect hidden behind the mathematics. It is the meaning of the model.
Occam’s razor is a probability budget
The phrase “Bayesian Occam’s razor” can mislead. It may sound as if the method rewards simple-looking equations or punishes parameter count by decree. The actual mechanism is predictive concentration. A parameter matters only through how it changes the distribution of possible observations. Two extra parameters that barely alter predictions may cost little. One parameter with a vast prior range may cost a great deal.
A local approximation makes the intuition visible. Imagine that the posterior occupies a narrow region of parameter space where the data fit well. The marginal likelihood is roughly the peak likelihood multiplied by the fraction of prior volume that remains plausible. This fraction is sometimes called an Occam factor. The approximation assumes a regular, well-identified model with a single dominant posterior region. Singular models, weak identification and multimodality can break the simple volume picture.
Stretch the prior, keep the best fit
Take the unknown-bias coin model. Keep its maximum-likelihood fit at 90 per cent heads. Now stretch the prior from a narrow distribution near 90 per cent to a uniform distribution, then to a shape that concentrates near zero and one. The best fit does not move, but the average prediction does.
The Bayes factor for nine heads against a fair coin is about 31.9 under a Beta(20, 2) prior, 9.31 under a uniform Beta(1, 1) prior and 4.33 under a sharply U-shaped Beta(0.1, 0.1) prior. Model comparison is therefore a comparison of whole predictive commitments, not fitted parameter points.
This is why diffuse priors are not automatically “uninformative” for model selection. A wider prior spreads probability over more possible datasets and can reduce marginal likelihood sharply. Improper priors, whose total mass cannot be normalised, do not define a marginal likelihood without additional construction. Prior sensitivity in Bayes factors is a documented practical issue, not a reason to conceal priors [Llorente et al., 2023].
Prior predictive checking turns a prior into an observable claim
Before fitting, draw parameters from the prior and simulate datasets from the likelihood. Ask whether the generated observations are plausible at the scale the real instrument could produce. If the model routinely generates impossible counts, times or magnitudes, the prior is more than “weak”. It is allocating predictive mass to worlds the analyst does not endorse.
Prior predictive visualisation is part of contemporary Bayesian workflow because it exposes the practical implications of parameter choices before the observed data dominate attention [Gabry et al., 2019]. The check does not prove the prior correct. It prevents a parameter label from hiding an incoherent predictive commitment.
Why better fit can produce weaker evidence
Maximum likelihood asks for the best parameter setting inside each model. Marginal likelihood asks for the model’s average pre-data prediction. These objectives can move in opposite directions. Add a parameter and the maximum likelihood cannot become worse because the old fit remains available. The marginal likelihood can fall because the new parameter opens predictive regions that the data did not occupy.
This distinction matters when a model is tuned repeatedly. If an analyst searches many priors, architectures or feature sets and reports only the one with the highest marginal likelihood, the search itself has created a larger effective model. The advertised comparison no longer describes the probability budget actually spent. One remedy is to include the search choices in the model hierarchy. Another is to reserve data for evaluating the completed process. The right remedy depends on whether the target is scientific comparison or future prediction.
A good report therefore shows both local fit and integrated evidence. The first reveals whether a model contains a parameter setting that matches the data. The second reveals whether that match was a concentrated prediction or a lucky point inside a broad possibility space. Neither number should be asked to do the other’s job.
Evidence accumulates through conditional prediction
For a sequence of observations, evidence can be written as a running contest. At each step, each model predicts the next datum conditional on what has already occurred. The log Bayes factors add:
This is the prequential view: judge a model through the sequence of probability forecasts it issues [Dawid, 1984]. A model may lose early, learn from data through its posterior, then recover. The trajectory reveals whether the final score came from steady predictive superiority or one decisive observation.
Copy the witness, keep the report
Five dashboards report the same anomaly. If each dashboard has an independent sensor, five concordant readings may produce much stronger evidence than one. Now reveal that all five dashboards copy the same upstream sensor. The visible reports remain five; the evidence unit becomes one.
Multiplying five likelihood ratios assumes conditional independence given each model. When reports share a cause, that assumption is false. Evidence count is determined by causal provenance, not by the number of screens, documents or agents that repeat it. A Bayesian calculation can be exact and still overstate evidence because its dependence graph is wrong.
The frame can win while reality loses
Bayesian model comparison normalises probability across the models supplied. If two candidates are both poor, one still receives the larger posterior probability. This creates a decisive boundary: comparison answers which candidate predicted better within the frame. It does not by itself answer whether the frame can generate the important features of reality.
Suppose two maps omit an island. One has a slightly better coastline elsewhere. A posterior probability of 0.93 for that map does not create the missing island. Relative victory and absolute adequacy are different inferential operations. Model comparison redistributes belief; model checking asks whether the shared assumptions should survive.
Comparison, checking and prediction answer different questions
Three tools are often collapsed into “model evaluation”, but they create different evidence.
| Tool | Question | Positive result permits | What it cannot establish |
|---|---|---|---|
| Bayes factor or posterior model odds | Which declared model assigned more prior predictive probability to these data? | Relative updating among fixed rivals. | That any rival is adequate, true or useful for a different decision. |
| Posterior predictive check | Can the fitted model reproduce a chosen feature of the data? | Failure detection and model revision. | That passing checks certifies the model, because checks are selective. |
| Leave-one-out predictive comparison | Which fitted model predicts held-out observations better? | Choice or combination for predictive tasks. | That the model’s internal explanation is causally correct. |
| Decision analysis | Which action has the best expected consequence under stated losses? | Action under uncertainty. | That the chosen action makes the most probable model true. |
Leave-one-out cross-validation estimates out-of-sample predictive accuracy using each observation as held-out data; Pareto-smoothed importance sampling makes the calculation practical for many fitted Bayesian models and supplies diagnostics for unstable approximations [Vehtari, Gelman & Gabry, 2017] [Vehtari et al., 2024]. It is not a substitute for a Bayes factor when the scientific question is a prior comparison of sharply specified hypotheses. It answers a different question.
The difference becomes important in an M-open setting, where none of the candidates is expected to be literally true. Predictive stacking chooses weights that optimise held-out predictive performance rather than interpreting posterior model probability as the chance that one candidate is the data-generating truth [Yao et al., 2018]. Recent work in machine learning also shows that marginal likelihood can be misaligned with generalisation when it is repurposed for hyperparameter or architecture selection after repeated data-dependent choices [Lotfi et al., 2022].
Remove the true island from the map
Generate observations from a periodic process. Offer the analyst only a straight-line model and a quadratic model. With enough data, the quadratic will usually win the comparison because it bends. Yet its predictive residuals will show a repeating pattern. Now add a sinusoidal rival. Probability mass moves again.
The experiment changes only the candidate set. It exposes a limitation that no amount of exact updating can repair from inside the old set. The practical requirement is an escape test: a discrepancy, intervention or held-out regime that can force model expansion rather than merely select a winner.
Did the agent use the retrieved evidence?
Consider a synthetic document-answering system called Kepler Desk. It retrieves a policy passage, sends the passage with a question to a language model, and returns an answer. On ordinary questions it scores well. That observation fits at least three rival generators.
Muse says the answer changes because the model causally uses the retrieved passage. Mtemplate says the model relies on memorised or stylistic patterns and would answer similarly without the passage. Mleak says the benchmark or prompt contains cues that reveal the expected answer. Accuracy on standard prompts gives all three models room to succeed.
A discriminating experiment changes the retrieved evidence while preserving question form. In ten normal trials, ten document-swap trials and ten no-retrieval trials, suppose the synthetic system gives nine expected answers, follows seven swapped documents and answers correctly three times without retrieval. Fixed predictive rates specified before the test yield a Bayes factor of about 10 for Muse over the stronger leakage rival, and about 879 over the template rival.
The large number against the weak template rival should not dominate the conclusion. The more decision-relevant comparison is against the stronger leakage rival because it survives more of the same observations. This is a general design rule: improve the rival before increasing the sample. More repetitions of a non-discriminating test can produce impressive certainty about the wrong contrast.
Open the synthetic likelihood calculation
For each condition, use a binomial likelihood for the observed number of successes. Muse predicts success rates (0.85, 0.70, 0.30) for normal, swapped and no-retrieval conditions. Mtemplate predicts (0.85, 0.30, 0.70). Mleak predicts (0.85, 0.55, 0.60). The synthetic outcomes are (9/10, 7/10, 3/10). Multiplying the three binomial probabilities gives relative likelihoods. These are Bayes factors only because the rates are treated as fixed model commitments and prior model odds are handled separately.
A better empirical study would place priors on condition rates, include trial-level dependence, preregister the intervention and test additional rivals such as prompt-position heuristics. The example shows the logic of discrimination, not a general measurement of “causal use”.
The strongest boundaries
Where posterior odds become fragile or misleading
Prior fragility: a Bayes factor can change materially across plausible parameter priors, especially for diffuse alternatives. Report a sensitivity surface, not one ornamental prior.
Candidate omission: a posterior winner can be the least wrong member of a poor set. Use posterior predictive discrepancies and out-of-domain tests.
Dependence error: repeated documents, agents or sensors may share one upstream cause. Model that cause or count the evidence once.
Data-dependent model invention: if models, priors or features were repeatedly tuned after viewing the data, the nominal marginal likelihood no longer represents the advertised pre-data commitment.
Decision mismatch: the most probable model need not imply the safest action. Costs, asymmetry and reversibility belong in a separate decision layer.
A tiny effect in a huge sample
Suppose a measurement has known standard deviation one. A study with 100 observations estimates a mean shift of 0.20. A second study with 10,000 observations estimates a shift of 0.02. Both estimates are two standard errors from zero, so a conventional two-sided significance calculation gives roughly the same p-value.
Now compare a point-null model, which fixes the shift at zero, with an alternative that spreads prior mass across shifts with standard deviation one. In the much larger study, the observed 0.02 is extremely close to the null on the scale allowed by the broad alternative. The null can receive greater Bayes-factor support even though the p-value remains near the same threshold. This family of disagreements is associated with the Jeffreys-Lindley phenomenon [Lindley, 1957].
The lesson is not that one framework is secretly computing the other incorrectly. The questions differ. A p-value measures how unusual a statistic is under the null and a specified sampling plan. The Bayes factor compares the null’s prediction with an alternative’s prior predictive distribution. Widen the alternative prior and the evidence can move further toward the null. Narrow it around practically meaningful effects and the result changes.
This edge case is a warning against universal evidence thresholds. A Bayes factor of ten has no context-free meaning when the prior, measurement resolution and decision scale are hidden. Report the predictive commitments and the effect sizes that matter, not only a verbal grade.
stateDiagram-v2 [*] --> Claim state "The odds form reveals the<br/>mechanism" as Claim state "A rare fault alarm" as Test state "Change the rival, keep the data" as Revision Claim --> Test: expose mechanism Test --> Decision: evidence survives Test --> Revision: rival survives Revision --> Claim: narrow or rebuild Decision --> [*]
Build a rival-first evidence contract
The practical mistake usually occurs before calculation. A team starts with a favoured explanation, collects observations that sound compatible with it, then asks for a posterior. The calculation becomes a polished endpoint for a one-sided design.
A better process starts from the decision and works backwards to a discriminating observation. The proposed rival-first evidence contract is a compact specification for doing that. It is practitioner synthesis, not a published statistical theorem. Its purpose is to make hidden modelling choices reviewable before a consequential update.
Bayes factors, prior and posterior predictive checks, LOO and stacking.
Whether posterior model probability should be read as scientific belief in M-open settings.
The rival-first evidence contract and escape-test requirement.
Teams using the contract will produce fewer evidence reversals under rival expansion.
Write rivals that can lose differently
A strong rival is more than the negation of the preferred model. “The system does not use evidence” covers many mechanisms with different predictions: memorised answers, prompt cues, a hidden database, majority-class guessing or a tool result copied after the fact. Combining them into one vague alternative makes the denominator impossible to interpret.
Start with the intervention that matters to the decision. Then work backwards. If the claim is causal use of retrieved evidence, change the evidence while preserving wording. If the claim is calibrated uncertainty, hold accuracy constant while changing base rates. If the claim is a stable internal representation, preserve output while perturbing the proposed representation. Each intervention should create a table of divergent predictions before data collection.
Do not require every rival to be equally detailed. Require each to be detailed enough to assign a probability to the decisive observation. When probabilities are hard to defend, use ranges and perform robust sensitivity analysis. The purpose is not false precision. It is to expose where the conclusion depends on a judgement that would otherwise remain verbal.
The seven fields
1. Decision. State what action can change, at what posterior or predictive threshold, and with which loss asymmetry. This prevents a probability estimate from being mistaken for a decision rule.
2. Rival generators. Describe at least two mechanisms capable of producing the observation. Include the strongest plausible mimic, not a straw alternative. A useful rival is generative: it says what would happen under interventions, not only how it labels existing data.
3. Prior predictive commitments. Specify model priors, parameter priors and the observations each model expects before seeing the test data. Simulate from them. Record which choices are substantive and which are convenience defaults.
4. Observation bridge. State how a latent mechanism becomes a measured datum. Include sensor error, annotation, prompt framing, missingness and selection. In possible-mind research, a report is an output channel, not a transparent window into experience.
5. Evidence units and dependence. Map shared sources, repeated transformations and conditional dependencies. Decide what can be multiplied and what must be modelled jointly.
6. Update and sensitivity. Report prior odds, Bayes factor and posterior odds separately. Vary plausible priors, likelihood noise and rival definitions. A conclusion that flips under modest changes should be carried forward as fragile.
7. Escape test. Name an observation that could reject the entire candidate frame, trigger a new rival or force abstention. This field stops posterior normalisation from masquerading as adequacy.
| Field | Question to answer before the update | Failure trigger | Required receipt |
|---|---|---|---|
| Decision | Which action changes, and what losses make the threshold sensible? | No stated consequence. | Decision and loss statement. |
| Rivals | Which mechanisms could generate the same observation? | Only the preferred story is generative. | Rival list with intervention predictions. |
| Commitments | What did each model predict before seeing test data? | Prior chosen to favour the observed result. | Prior predictive simulation. |
| Observation bridge | How do mechanism and measurement connect? | Unknown or ignored error channel. | Measurement model. |
| Dependence | Which observations share causes or sources? | Repeated representation counted as new evidence. | Provenance graph. |
| Update | How do priors, Bayes factors and posteriors change across plausible choices? | Material sign reversal. | Sensitivity surface. |
| Escape | What result forces model expansion or abstention? | No way for all rivals to lose. | Predeclared discrepancy or held-out regime. |
Rival-first design should reduce evidence reversals
The hypothesis is that teams required to complete the seven fields before collecting test data will show fewer reversals when an independent reviewer adds a strong rival or traces evidence provenance. It would be strengthened by preregistered studies showing improved out-of-sample discrimination without excessive review burden. It would be weakened if the contract adds ceremony but does not change model sets, interventions or decisions.
A rival explanation is that any structured preregistration would produce the same improvement. The proposal should therefore be compared with a generic analysis plan, not with an unstructured baseline alone. It should not be applied as a heavy gate to trivial, reversible decisions. The smallest useful implementation is two rivals, one intervention, one sensitivity grid and one escape condition.
Executable lab: a browser Bayesian notebook
The lab below compares a fixed-probability model M0 with a composite Bernoulli model M1. Under M0, the success probability is fixed at p0. Under M1, it has a Beta(α, β) prior. Enter observed successes and trials, then inspect the Bayes factor, posterior model probability and sensitivity to the prior.
Rival-first Bayesian notebook
All calculations run locally in this page. No data leave the browser.
What it tests. The notebook exposes how evidence changes when the observation, model prior or parameter prior changes. What a positive result permits. A Bayes factor above one permits a relative update toward M1 under the entered models. What a negative result means. A value below one transfers odds toward M0; it does not prove M0. What it cannot establish. The notebook cannot detect omitted rivals, dependent trials, a wrong observation model or data-dependent prior selection.
Python version of the notebook
Save the following as bayes_model_compare.py and run it with Python 3. It uses only the standard library.
from math import exp, lgamma, log
def log_beta(a: float, b: float) -> float:
"""Log of the beta function for positive a and b."""
if a <= 0 or b <= 0:
raise ValueError("Beta prior parameters must be positive")
return lgamma(a) + lgamma(b) - lgamma(a + b)
def compare_binomial_models(
successes: int,
trials: int,
p0: float = 0.5,
alpha: float = 1.0,
beta: float = 1.0,
prior_m1: float = 0.5,
) -> dict[str, float]:
"""
M0: fixed Bernoulli probability p0.
M1: Bernoulli probability p with Beta(alpha, beta) prior.
Invariants:
0 <= successes <= trials; 0 < p0 < 1;
alpha, beta > 0; 0 < prior_m1 < 1.
"""
if not (0 <= successes <= trials):
raise ValueError("Require 0 <= successes <= trials")
if not (0 < p0 < 1 and 0 < prior_m1 < 1):
raise ValueError("Probabilities must lie strictly between 0 and 1")
failures = trials - successes
log_m0 = successes * log(p0) + failures * log(1 - p0)
log_m1 = (
log_beta(successes + alpha, failures + beta)
- log_beta(alpha, beta)
)
log_bf10 = log_m1 - log_m0
bf10 = exp(log_bf10)
prior_odds = prior_m1 / (1 - prior_m1)
posterior_odds = prior_odds * bf10
posterior_m1 = posterior_odds / (1 + posterior_odds)
return {
"bf10": bf10,
"log_bf10": log_bf10,
"posterior_m1": posterior_m1,
"posterior_mean_p_m1": (successes + alpha) / (trials + alpha + beta),
}
if __name__ == "__main__":
print(compare_binomial_models(successes=9, trials=10))
The binomial coefficient cancels in the Bayes-factor ratio because both models assign it to the same count. If the observation protocol differs across models, that cancellation may not be valid. This is one reason to specify the observation bridge explicitly.
Choosing the comparison tool
Use posterior model odds or Bayes factors when rivals are substantive generative hypotheses, priors are proper and fixed before the test, and relative evidence is the target.
Use prior and posterior predictive checks when the immediate question is whether a model’s implications are plausible or whether the fitted frame misses decision-relevant structure.
Use LOO predictive comparison or stacking when future prediction is the goal and no candidate is expected to be literally true.
Use decision analysis after inference when actions have unequal costs, irreversible consequences or asymmetric protection requirements.
This division is consistent with a broader Bayesian workflow in which inference, checking, revision and comparison form an iterative process rather than a single calculation [Gelman et al., 2020]. Gelman and Shalizi argue that successful Bayesian practice includes model criticism and revision, not only conditional updating inside a fixed model [Gelman & Shalizi, 2013].
sequenceDiagram participant Q as Question participant M as Mechanism participant E as Evidence participant D as Decision Q->>M: The coin that became less convincing when the alternative became more flexible M->>E: The odds form reveals the mechanism E-->>M: compare rival explanations E->>D: Make rival generators disagree before updating belief D-->>Q: revise scope or act
Make rival generators disagree before updating belief
Do not begin an uncertain investigation by asking, “How much does this result support my explanation?” Begin by asking, “Which rival generators could have produced the same result, and what observation would make their predictions diverge?”
Then declare the prior predictive commitments, measurement channel and evidence dependence. Update prior odds with a predictive ratio. Check whether the winning model can reproduce the features that matter. Test whether the result survives plausible priors and a stronger rival. Only after those steps should posterior belief enter a decision rule.
The practical shift is from confirmation to discrimination. A fluent report, a benchmark score, a neural correlate or a repeated dashboard does not become strong evidence because it fits a compelling story. It becomes evidence when another story put a different probability on the same observation, the observation bridge is defensible, and the candidate frame retains a route to failure.
Probability is not a machine for making uncertainty disappear. It is a discipline for showing exactly where uncertainty moved, what assumption moved it and which alternative could move it back.
Glossary
- Bayes factor
- The ratio of the marginal likelihoods of the same observation under two rival models. It measures relative evidential force, not posterior probability by itself.
- Likelihood
- A model’s probability or density for observed data at a specified parameter value. It is a function of the parameter once the data are fixed.
- Marginal likelihood
- The likelihood averaged over a model’s parameter prior. It is the model’s prior predictive probability or density for the observation.
- Posterior odds
- The relative probability of two models after observing data. Posterior odds equal prior odds multiplied by the Bayes factor.
- Prior predictive check
- A simulation of observable data from priors and likelihood before fitting, used to expose implausible predictive commitments.
- Posterior predictive check
- A comparison between observed data and replications generated from the fitted model, targeted at chosen discrepancies.
- M-open setting
- A setting in which the actual data-generating process is not assumed to be one of the candidate models.
- Escape test
- A predeclared observation or discrepancy that can reject the whole candidate frame, trigger rival expansion or require abstention.
References
- Bayes, T., & Price, R. (1763). An essay towards solving a problem in the doctrine of chances. Philosophical Transactions of the Royal Society of London, 53, 370–418.
- Dawid, A. P. (1984). Statistical theory: The prequential approach. Journal of the Royal Statistical Society, Series A, 147(2), 278–292.
- Gabry, J., Simpson, D., Vehtari, A., Betancourt, M., & Gelman, A. (2019). Visualization in Bayesian workflow. Journal of the Royal Statistical Society, Series A, 182(2), 389–402.
- Gelman, A., Meng, X.-L., & Stern, H. (1996). Posterior predictive assessment of model fitness via realized discrepancies. Statistica Sinica, 6, 733–807.
- Gelman, A., & Shalizi, C. R. (2013). Philosophy and the practice of Bayesian statistics. British Journal of Mathematical and Statistical Psychology, 66, 8–38.
- Gelman, A., Vehtari, A., Simpson, D., Margossian, C. C., Carpenter, B., Yao, Y., Kennedy, L., Gabry, J., Bürkner, P.-C., & Modrák, M. (2020). Bayesian workflow. arXiv:2011.01808.
- Hoeting, J. A., Madigan, D., Raftery, A. E., & Volinsky, C. T. (1999). Bayesian model averaging: A tutorial. Statistical Science, 14(4), 382–417.
- Kass, R. E., & Raftery, A. E. (1995). Bayes factors. Journal of the American Statistical Association, 90(430), 773–795.
- Lindley, D. V. (1957). A statistical paradox. Biometrika, 44(1–2), 187–192.
- Llorente, F., Martino, L., Curbelo, E., López-Santiago, J., & Delgado, D. (2023). On the safe use of prior densities for Bayesian model selection. WIREs Computational Statistics, 15(1), e1595.
- Lotfi, S., Izmailov, P., Benton, G., Goldblum, M., & Wilson, A. G. (2022). Bayesian model selection, the marginal likelihood, and generalization. Proceedings of the 39th International Conference on Machine Learning, 14223–14247.
- Vehtari, A., Gelman, A., & Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing, 27, 1413–1432.
- Vehtari, A., Simpson, D., Gelman, A., Yao, Y., & Gabry, J. (2024). Pareto smoothed importance sampling. Journal of Machine Learning Research, 25(72), 1–58.
- Yao, Y., Vehtari, A., Simpson, D., & Gelman, A. (2018). Using stacking to average Bayesian predictive distributions. Bayesian Analysis, 13(3), 917–1007.