7 Estimation
Given indepedent observations that come from some unknown, true probability distribution , how do we infer ?
Moment Estimation: Estimate the mean and variance of the data.
Finding the full mathematical curve (the distribution) that best fits your dataset, bu tuning parameters. By learning this underlying shape, AI models can sample from it to generate new, realistic synthetic data.
Regression/Classification: Supervised learning, where the observations come in pairs. An input and its corresponding label, denoted as . The goal is to estimate the relationship between them, such as predicting the conditional probability of a label given an input () or the expected value ().
7.1 Estimator/Estimate
The primary goal of statistical inference (or learning) is to
construct an estimator for
.
This
represents a true, unknown parameter associated with a probability
distribution
.
Examples of this parameter include the mean, the variance, or the
parameter of a probabilistic model,
.
Estimator vs Estimate:
Estimator: This is defined as a random variable, , that depends on your data observations (). It is the overarching mathematical formula or rule, written as .
Estimate: This is the actual output you get when you plug specific, concrete data points () into your estimator formula. It is the final calculated result, written as .
The 4 criteria to evaluate if an estimator is good:
Unbiasedness: An estimator is unbiased for a true parameter if . The average of many estimates is the true answer.
Consistency: An estimator is consistent for a true parameter if . A single estimate becomes perfectly accurate with enough data.
Effectivity: An unbiased estimator is considered more effective if it has a lower variance than another unbiased estimator, i.e. the confidence is greater.
Asymptotic normality: As , distribution of your estimator’s guesses will start to perfectly resemble a Normal Distribution (a classic bell curve) centered around the true parameter, by the CLT.
7.1.1 Bias-variance decomposition
When we create an estimator
()
to guess a true, unknown parameter
(),
we need a way to mathematically measure how "good" that guess is.
The motivation: Suppose you have independent data
points
and you want to estimate the true mean.
(The sample mean, averaging data points).
(Just the first data point).
Both estimators are unbiased, i.e. if you repeat the experiment
infinitely many times, both will eventually average out to the true
mean.
However, intuitively,
is a much better estimator, as it uses all the data, meaning it will
fluctuate much less from sample to sample.
will wildly jump around depending on what that first data point happens
to be.
().
The standard way to measure the quality of estimators by calculating the Expected Squared Error: . In other words, on average, how far away is our estimator’s guess from the actual true parameter? We can break this ESE into two separate parts: Notice that this translates to: Total Error = Variance + .
Variance : The first term () measures how much the estimator’s predictions bounce around its own average. It represents the estimator’s sensitivity to the specific random sample of data you pulled.
Bias Squared : measures the difference between the estimator’s average prediction and the actual true parameter. It tells you if your estimator is systematically missing the mark.
What this means for statistical inference: If an
estimator is completely unbiased, its Bias term is exactly 0. Therefore,
its total Expected Squared Error is equal only to its Variance
().
An Efficient Estimator is thus one that is unbiased AND has the minimum
variance.
7.1.2 Fisher Information and Cramér-Rao Lower Bound
To find an efficient estimator, we need a mathematical floor for the
absolute minimum variance.
Firstly, the Fisher Information, denoted as
quantifies the amount of information that an observable random variable
carries about an unknown parameter
.
If changing the true parameter drastically changes the probability of
our data, the data carries a lot of Fisher information.
It is defined as the expected value of the squared derivative of the
log-likelihood:
Next, the Cramér-Rao Inequality states that the variance of any unbiased
estimator
cannot possibly be smaller than the inverse of the total Fisher
Information provided by the
data points.
Note that as
or the data is highly informative
(
is large), the Cramér-Rao lower bound gets close to zero, meaning it
becomes mathematically possible to create a highly precise estimator
with very little variance.
7.2 Mean Estimation
Given independent observations
,
find the unknown, true mean of the distribution,
.
Define an estimator, the sample mean
The sample mean is itself a random variable.
Note that
refers to the first moment of the distribution, and
is i.i.d.
Three properties of a good estimator:
Unbiased: .
Variance shrinks with data: . Shows Effictivity and proves Consistency.
Consistent: , .
7.2.0.1 Example
For some distributions, their parameter is equal to the theoretical mean.
Bernoulli distribution .
Poisson distribution .
Since we know the sample mean is a great estimator for the theoretical mean, we just find the sample mean to estimate the parameters.
7.3 Variance Estimation
Given independent observations
,
estimate the variance
.
Define an estimator, the sample variance
This estimator is biased, i.e.
.
Proof.
Define a corrected
estimator:
Consistency: Both
and
are consistent. As
,
the difference between dividing by
versus
becomes negligible, and both converge to the true variance.
7.4 Probability Density Estimation
Given training data/observations
,
,
we choose a probabilistic model (hypothesis class of PDFs)
.
We want to find the specific parameters
that make the model
the best possible approximation of the true distribution
by fitting it to the training data.
For example, a common template to use is the Gaussian distribution. The
parameters to tune are the mean and the variance, so as to fit the
data.
Another example, Generative AI. Training the model entails analyzing
existing examples to find the underlying probability distribution that
generated them. Then during generation phase, the model draws new data
samples from those estimated distributions. This random sample becomes a
brand-new, synthetic image or piece of text that looks authentic because
it follows the probability rules of the original data.
7.4.1 Maximum Likelihood Estimation (MLE)
We want to find the parameter
that makes the occurrence of
as likely as possible, i.e.
Since we assume the observations are i.i.d.,
If
is huge, this number is very small and computers cannot handle it. Hence
we take logarithm (recall the property
).
Hence, MLE is solving for
For very complex distributions (like deep neural networks), solving this
maximization problem directly is often impossible (intractable).
Hence, use approximation methods like EM algorithm, variational Bayes /
variational autoencoders (VAEs), diffusion models.
7.4.2 Kullback–Leibler (KL) divergence
KL divergence is a statistical measure that quantifies how one
probability distribution differs from a second, reference probability
distribution.
In estimation context, KL divergence shows how closely our estimated
model
matches the true data distribution
.
For continuous probability densities
and
,
the KL divergence between them is
Two properties of KL divergence:
Non-negativity: .
Identity: if and only if the two distributions are identical ().
7.4.3 Connection between MLE & KL divergence
From the standard MLE sum, multiply by to get the empirical average: As , the empirical average converges to the theoretical expected value over the true data distribution , by Law of Large Numbers, To connect this to KL divergence, first subtract a constant. Maximising the log-likehood minimises the KL divergence.
7.4.4 Example - Bernoulli Distribution
Given random variable
,
,
,
Observations are
,
(),
which are i.i.d. The likelihood function is
Since the product is hard to calculate, the log likelihood function is
To find
that maximises the function, take the derivative wrt
and set to 0:
Solving, we get
The most optimal way to estimate the probability here is just the sample
mean.
For example, given 10 coin flips,
,
.
Interpretation: The parameter that makes this specific dataset the most
mathematically likely to occur is
.
Is this estimator efficient? (has the lowest possible
variance)
For a Bernoulli distribution, the variance of a single trial
is known to be
.
Then,
We start with the
log-likelihood of a single Bernoulli trial:
Using the definition of Fisher information:
Then the Cramér-Rao Lower
Bound is:
The
implication:
is an efficient estimator.
7.4.5 Example - Multivariate Gaussian Distribution
Moving from just a single variable
,
we now consider data points in
-dimensional
space
.
Define the mean vector
,
which is a vector that contains the average value for every single
dimension, and
.
Also, define the covariance matrix
,
which is a square matrix that captures the variance. Here,
.
It tells us the variance of each individual dimension and how all the
dimensions correlate with one another.
Recall the
-variate
Gaussian PDF:
with the normalisation constant in the front, and the term in the
exponent calculating the "distance" of point
from the mean
,
scaled by the covariance.
The goal is to use MLE to calculate
and
that best fit the data.
Taking derivative of this function w.r.t. to
and
and setting it to zero,
Conclusion: Applying MLE to a multivariate Gaussian distribution gives us the sample mean and the sample covariance matrix as our optimal estimators. As the number of samples increases, these calculated estimates will converge to the true, underlying parameters and of the distribution.
7.5 Bayesian Inference
Methods like MLE treated the parameter
as a fixed, absolute, but unknown constant to solve for.
Bayesian Inference instead considers a probability distribution of
.
is treated a random variable with its own probability distribution, and
we can update our entire belief about the parameter as we gather more
data.
The probabilistic structure is:
Prior Distribution, : initial belief about the distribution of the parameter before you have observed any data.
Likelihood, : how likely you are to observe the data , assuming a specific parameter is true.
Joint Distribution, : combined probability of both the parameter and the data occurring.
The goal is to infer
by calcuting the posterior distribution using Bayes’ Theorem:
The numerator can be written as the product of individual likelihoods
since the observations are independent. The
here represents the specific hypothesis we are currently testing.
The denominator calculates the total marginal probability of observing
this specific set of data. We use the dummy variable
here to show that this integral sweeps across every possible value of
the parameter to calculate a grand total. Because it integrates out the
parameter, the denominator evaluates to a flat constant number.
With this updated belief, we want to make a prediction about new, unseen
data. In other words, given all the past data observations
I have already seen, what is the probability of observing a completely
new data point
?
We want to solve for
,
the posterior predictive distribution.
The expected value is calculating the weighted average of the likelihood
,
where the "weights" are determined by how plausible each
is according to your posterior distribution
.
Recall that if we used MLE, we would have calculated the single best
parameter
,
and to predict a new data point, we just plug it into
.
The expected value of a continuous function is found by integrating it over the probability distribution. Multiplying () by the weights () and integrating over , Conclusion: Because Bayesian inference averages over all possible parameters rather than relying on a single estimate, its predictions are much safer, especially when you have very little data. If your dataset is small, your posterior distribution will be wide (highly uncertain). The integral naturally accounts for this uncertainty, preventing you from making overconfident predictions based on a small sample size. As you gather more data (), your posterior distribution becomes an incredibly narrow spike around the true parameter, and this massive integral mathematically simplifies down to become virtually identical to the MLE approach.
7.5.1 Bayesian Inference with Gaussian Distribution
Calculating that massive integral in the denominator to find the
posterior is often computationally impossible for complex
distributions.
Instead, we can the use a property of Gaussians: if your prior is a
Gaussian, and your likelihood is a Gaussian, your resulting posterior is
guaranteed to also be a Gaussian.
First, model the prior and likelihood by Gaussian distributions:
The Prior, : Before seeing any data, you believe the true parameter is somewhere around , but you have some uncertainty, represented by the variance .
The Likelihood (): Observing data points , under the assumption that these data points are generated by a Gaussian distribution centered around the true parameter , with a known variance of .
After observing
data points, the belief updates. The posterior variance
and posterior mean
are
As
,
The uncertainty drops to 0, and the mean becomes exactly equal to the
sample mean, ignoring the initial belief.
Conclusion: Recall that the sample mean
is the exact solution you get when you use MLE.
Bayesian Inference is asymptotically equivalent to MLE.
In small data regime (we have little data), MLE is vulnerable to extreme
outliers and overfitting. Bayesian inference instead anchors the
prediction to your prior belief.
In large data regime, the sheer volume of evidence overwhelms whatever
initial bias or belief you had. The prior’s influence vanishes, and the
Bayesian approach perfectly mathematically aligns with the Frequentist
(MLE) approach.
7.5.2 Maximum a Posteriori Estimation
In Bayesian inference, the perfect way to make a prediction is to
calculate
.
However, this is intractable. This means that for complex, real-world
models (like deep neural networks), the integrals required to calculate
the full posterior and the expected value are too complicated and
computationally heavy for a computer to actually solve.
Instead of averaging all possible parameters, MAP Estimation simply
finds the single most likely parameter value at the very peak of the
posterior distribution curve.
This value is denoted as
,
and it is found by taking the
of the posterior:
Specifically, the core MAP equation is
There are two distinct parts in this equation:
The data likelihood : This is the same log-likelihood term we maximized in standard Maximum Likelihood Estimation (MLE). It pushes the model to pick parameters that fit the observed data well.
The prior as a penalisation term : This is the log of your prior distribution acting as a penalisation term. If the MLE part tries to pick an extreme parameter that perfectly fits the data but goes against your initial beliefs, this prior term will mathematically penalize (reduce) the overall score.
Because of this added prior term, this problem is also called
penalized maximum likelihood estimation.
Also, as
,
the data likelihood term (which is a sum) becomes massive, completely
overwhelming the single, static
prior term. With enough data, MAP becomes identical to MLE.
After finding this single best parameter, we can use it to make
predictions as
.
MAP uses Bayesian logic (incorporating a prior belief) but outputs a
single parameter like the Frequentist MLE approach.