Mathematical Prerequisites for Foundation Prior
Building the math foundations for understanding how LLMs reshape Bayesian priors — parameters, likelihood, Beta distributions, KL divergence, entropy, exponential tilting, and marginal likelihood — all derived step by step with one coin example.
Before diving into the Foundation Prior paper, you need a handful of mathematical ideas. This post builds every one of them inside a single, consistent coin-flip example so nothing feels abstract or disconnected. By the end, you will have all the tools required to understand how synthetic data from LLMs can be incorporated into Bayesian inference in Part 2.
The Running Example
Imagine we flip a coin 10 times and observe:
The coin might be biased. We do not know the true probability of Heads. Our goal throughout this post is to figure out what that probability might be, and to build every mathematical tool we need along the way.
What Is a Parameter?
A parameter is just an unknown quantity that controls how the data is generated. That is the entire definition. It does not automatically mean probability. It does not automatically mean mean or variance. It means: “the hidden setting of the system.”
In our coin example, we introduce a model where each flip has probability of being Heads and probability of being Tails, and the probability stays the same across flips. Here is the parameter. In this model, the parameter happens to be a probability. That is allowed — a parameter is just an unknown number, and sometimes that number represents a probability.
Two outcomes does not mean . All we know is:
The coin might be biased. So we allow and try to learn from data.
In other models, the parameter could be a mean (), a variance (), a slope (), a rate (), or a vector of many numbers. The symbol just stands for “unknown.” Its meaning depends on the model.
What Is a Model?
A model is a mathematical description of how the data is generated. For the coin, the model says that the probability of Heads is and that flips are independent. That is the entire model. Without a model, you cannot compute probabilities. Without probabilities, you cannot construct likelihood.
Constructing the Likelihood
We observed HHHHHHHTTT — 7 Heads and 3 Tails. We ask: if the coin’s true probability of Heads were , what is the probability of seeing exactly this outcome?
For one Head, . For one Tail, . Since flips are independent, we multiply probabilities:
We did not invent a special formula. We simply wrote the joint probability of the observed data.
Numerical check
If we plug in :
That means: if the coin truly gives Heads 70% of the time, the probability of observing 7H3T is about 0.22%. That is an ordinary probability statement.
Likelihood vs. Probability
Then why call it likelihood? Because we now treat that same probability formula as a function of . We compare different guesses: gives a very small value, gives a larger value, and gives a smaller value again. The value of that makes the observed data most plausible is the best explanation. That comparison process is what we call likelihood.
Probability asks: if is fixed, what data might happen? Likelihood asks: given what happened, which makes sense? Same formula. Different question.
Why are likelihood values small?
All values are small. That is normal. Exact sequences are rare. Likelihood is not about absolute size — it is about relative comparison.
The observed data is 30,000 times more likely under than under . That comparison is powerful.
The general rule for constructing likelihood
Whenever you want to construct a likelihood, you define the model (how data is generated), write the probability of one observation, multiply across observations (if independent), and treat the result as a function of the parameter. That is all likelihood ever is.
One-sentence summary: Likelihood is the joint probability of the observed data, viewed as a function of the unknown parameter.
The Beta Distribution
What Beta really is
The Beta distribution is a mathematical way to represent prior fake observations of heads and tails. Nothing mystical.
Why it works perfectly for coins
When you flip a coin, the likelihood looks like . A Beta prior looks like . Multiply them:
Which is again a Beta distribution. That is why it is called a conjugate prior — the math stays in the same family.
Shape intuition
Beta can look flat (uniform), peaked in the middle, skewed toward 0, skewed toward 1, U-shaped, or extremely concentrated — all controlled by and . So it is extremely flexible.
Think of it this way: if is large, you have “seen many heads.” If is large, you have “seen many tails.” So Beta is just memory of imaginary past flips. Not real flips — belief flips.
Deriving the Beta Distribution From Scratch
Step 1 — What do we want?
We want a distribution over (probability of heads). After seeing heads and tails, we know the likelihood is:
That is not a definition — that is just how probabilities multiply. So any distribution that wants to behave like “fake data” must look like .
Step 2 — Build it from scratch
Suppose we say: “Before seeing data, I want my belief to behave exactly like I had already seen heads and tails.” Then the function representing that belief should look like:
Because that is exactly what real data would produce.
Step 3 — Rename the parameters
Instead of calling them and , statisticians define:
So and . Substitute back:
That is literally it.
Step 4 — Why the ?
It is just a definition choice. They could have defined Beta using . But historically, mathematicians defined the Beta function as:
So statistics inherited that form. The exists because the Beta distribution parameters are defined one higher than the fake counts.
Step 5 — Why define it that way?
Because of a convenience: when , the distribution becomes:
That gives a flat (uniform) distribution. If they had used , then uniform would occur at , and zero parameters are awkward. So they shifted everything by 1.
The exists because Beta parameters are defined so that Beta(1,1) = uniform, and are always positive. It is a parameterization choice, not a deep mystery.
The mean of a Beta distribution
The mean of is:
It represents the expected value or balance point of the distribution. For example, if and , then .
The variance of a Beta distribution
The variance of is:
This formula tells you how spread out the distribution is. As grows (more pseudo-observations), the variance shrinks — you become more certain. For example, has variance , while has variance — ten times more pseudo-observations gives roughly ten times less variance. We will use this formula in the law of total variance section below and again in Part 2 when computing mixture uncertainty.
What Is Entropy?
Entropy measures how uncertain you are. More spread out belief means more entropy. More concentrated belief means less entropy.
Simple example
Suppose can only be . Consider Belief A, which assigns probability 0.05 to , probability 0.05 to , and probability 0.90 to . This belief is almost sure , so it has low uncertainty and low entropy. Now consider Belief B, which assigns probability 0.33 to each value. This belief is very spread out, so it has high uncertainty and high entropy.
The formula
For discrete distributions, entropy is . For continuous distributions:
Why log appears
Log measures information. If something is very unlikely, is very negative. Entropy averages “how surprising outcomes are” weighted by probability. So entropy measures average surprise. More spread distribution means more surprise means more entropy.
The maximum entropy principle
Suppose you only know one thing: the average of is 0.6. But you know nothing else. There are infinitely many distributions with mean 0.6.
The maximum entropy principle says: choose the most spread out distribution that satisfies the constraint. Meaning: do not assume anything extra beyond what you are forced to assume. This will connect directly to the paper’s core optimization in Part 2.
KL Divergence
KL divergence measures how different two probability distributions are. It is defined as:
If , then (no change). Bigger KL means you moved farther from the reference distribution.
Three critical properties
First, it respects probability structure. It compares distributions multiplicatively, not additively. Probabilities combine multiplicatively (likelihoods multiply), and KL respects that.
Second, it measures information gain. KL equals the expected log difference. It literally measures: how many extra bits are needed if I encode reality using but truth is ? So minimizing KL means: add as little new information as possible.
Third, it uniquely produces exponential tilting. There is a theorem: if you minimize KL subject to expectation constraints, the solution must be exponential in the constraint function. No other divergence gives that clean structure.
Why not just subtract distributions?
Suppose we measured . That measures squared difference. The problem: it ignores that probabilities must remain positive, it does not respect the geometry of probability distributions, and it does not lead to Bayesian updating form.
Connection to maximum entropy
When you already have a prior , the correct generalization of maximum entropy is: minimize subject to constraints. This is called relative entropy maximization — the Bayesian version of maximum entropy. You are saying: given my old belief , and given that some constraint must hold, what is the least informative update?
Exponential Tilting
Start with a prior distribution . Suppose you want to favor larger values of some function . Instead of redefining everything from scratch, you tilt the prior by multiplying it by , then normalize:
You are “tilting” the original distribution toward higher values of .
Discrete coin example
Let only take three values: , with prior probabilities 0.3, 0.4, and 0.3 respectively. Now suppose synthetic data prefers larger . Let and choose .
First, compute for each value:
Now multiply each prior probability by its corresponding tilt factor:
The total is . Dividing each product by this total gives the new (normalized) probabilities:
The distribution shifted toward larger . Before tilting, had probability 0.30. After tilting, it has probability 0.49. That is exponential tilting — the prior was reweighted toward values that score higher on .
The theorem (Csiszar’s I-projection)
If you solve:
Then the unique solution must be:
This result is known as Csiszar’s I-projection theorem. No other shape works — the exponential form is not assumed, it is forced by the structure of KL. You will see this theorem invoked by name in Part 2 when we derive the foundation prior.
Why exponential form appears
KL divergence contains . When you take the derivative with respect to , you get . Solving for requires exponentiating. That is why the exponential form appears.
Where exponential tilting appears
This is not just used in the Foundation Prior paper. It appears in maximum entropy distributions, exponential families, large deviation theory, variational inference, and statistical mechanics. It is a fundamental geometric property of probability distributions.
Why We Use Log-Likelihood
If we have independent observations, the likelihood multiplies:
Taking the log turns products into sums:
This matters for three deep reasons. First, additivity: sums are far easier to optimize than products, which makes optimization tractable. Second, information geometry: KL divergence and log-likelihood live in the same exponential family geometry, and using log ensures duality between the constraint and the objective. Third, convexity: log-likelihood is often concave, making optimization easier, whereas if raw likelihood were used, the problem would be non-convex.
Coin example
For our coin with 7 Heads and 3 Tails:
This is just a score: bigger (less negative) means explains the data better.
Marginal Likelihood
Marginal likelihood answers this question: if my belief about is , how probable is the observed data overall? It is defined as:
You do not know the true . So to compute how likely the data is under your model, you assume could be many values, compute the likelihood for each possible , weight it by how plausible is under your prior, and average across all . That average is the marginal likelihood.
Coin example
Suppose can only be with equal prior probabilities. Real data: 6 heads out of 10. The likelihoods are:
The marginal likelihood averages these weighted by prior belief:
Notice that is about 2.25 times larger than — the data (6 heads out of 10) favors over . But the marginal likelihood combines both possibilities into a single number that measures how well the overall model (both values of together) predicts the data.
Why it is called “marginal”
Because we integrated out . We removed from the expression. So we now have probability of data alone — disappears.
Why marginal likelihood matters
It answers: how good is my entire model at explaining the data? Not just “what is best,” but: how well does the model as a whole predict reality? That is why it is used for model comparison, mixture weight updating, and trust parameter calibration — all things we will need in Part 2.
The important distinction to keep in mind: likelihood depends on , while marginal likelihood has no left — it is averaged over uncertainty.
The Law of Total Variance
This result will be needed when we average foundation priors across multiple prompts in Part 2.
Setup
Suppose you have a mixture distribution — a weighted average of component distributions. To sample from a mixture, you first randomly pick a component (say A, B, or C), then sample from that component’s distribution. This is equivalent to introducing a random variable with known probabilities, and then drawing .
The law of total expectation
The mean of a mixture is simply the weighted average of component means. If each component has mean and weight , then:
This is the law of total expectation: .
The law of total variance
The variance identity is:
This says: total variance = average within-component variance + variance of component means.
Concrete example
Suppose three components with equal weight , means , , , and variances , , .
The mixture mean is:
The first term (average within-component variance) is:
The second term (variance of component means) is:
So the total mixture variance is approximately .
Interpretation
Total uncertainty has two sources. Within-component uncertainty means that even if you knew which component was correct, you would still be uncertain about . Between-component uncertainty means you are also uncertain about which component is right. The mixture variance captures both.
Bayesian Updating (The Core Mechanic)
Before we move to the Foundation Prior paper, let us establish the standard Bayesian update — the baseline that the paper modifies.
You start with a prior , which represents your belief before seeing data. The likelihood tells you how likely the data is under parameter . The posterior is your belief after seeing data. Bayes’ rule says:
The prior is your belief, the likelihood is what the world tells you, and the posterior is their combination.
Coin example
Take a prior of , meaning . The data is 7 Heads and 3 Tails, giving likelihood . The posterior is:
That is . This is Beta-Bernoulli conjugacy — the Beta prior and the Binomial likelihood multiply to give another Beta. The prior contributed pseudo-head and pseudo-tail, and the data contributed 7 real heads and 3 real tails, giving . The posterior mean is .
Everything is clean because data comes from reality. The Foundation Prior paper (Part 2) asks: what happens when data comes from an LLM instead?
Summary
We built seven mathematical tools, all from one coin example. A parameter is an unknown number controlling data generation. Likelihood is the joint probability of observed data viewed as a function of the parameter. The Beta distribution encodes prior fake observations of heads and tails and stays Beta after updating — that is conjugacy. Entropy measures uncertainty, and the maximum entropy principle says: do not assume more than your constraints force. KL divergence measures how far a new belief is from an old one, and minimizing it under expectation constraints uniquely produces exponential tilting — multiplying the prior by . Marginal likelihood integrates out the parameter to give a single number measuring how well the entire model predicts data. And the law of total variance decomposes mixture uncertainty into within-component and between-component parts. In Part 2, every one of these tools will be used to derive the Foundation Prior framework from scratch.
Previous: MaxRL: From REINFORCE to Maximum Likelihood
Next: Foundation Prior: How LLM Outputs Reshape Bayesian Beliefs
Enjoyed this post?
Subscribe to get notified when I publish new posts. No spam, unsubscribe anytime.