In Part 1 of this post, I described why and how to find parametric models that describe real-world phenomena, and ended with a question: once you have a model, how certain are you that your parameter estimate is the right one? In this post, I’ll introduce an informal notion of uncertainty and describe how to quantify it using martingales, without a Bayesian prior.
As a reminder:
Parameter uncertainty
In this post, my notion of uncertainty is captured by the following criterion:
“I am certain of my estimate of
I’ve been interested in uncertainty for a long time (here are a bunch of posts and a paper). But in this post I’m going to focus on a method I recently learned about that uses martingales (I’ll define this shortly) to make uncertainty quantification of models a lot easier.
Quantifying uncertainty as a Bayesian
One way of quantifying parameter uncertainty is through the framework of Bayesian probability.
Under this framework, uncertainty over parameters
When we quantify the uncertainty of our estimate of
where
The likelihood belief captures any randomness in your function
where
For the purposes of this post, you can think of Bayes’ rule as a black box that takes in your prior belief
For example, let’s say the unknown parameter is the outside temperature today.
It’s summer, so you believe with 90% certainty that it will be hot, i.e.,
Here’s the big issue with Bayesian probability: where does the prior come from?
In the temperature example it’s easy: you know it’s summer and you know summers tend to be hot.
But what if you’re Newton and you’re trying to figure out what the gravitational constant
So now the question is: can we compute a posterior without a prior? The answer is yes, and in the next section I’ll show you how.
Quantifying parameter uncertainty without a prior
The key idea: instead of thinking about uncertainty as a function of some (unfounded) prior, think about it as the sensitivity of your learning procedure. If the data had been any different (but still sampled from the same distribution), would your learning procedure have resulted in a completely different parameter estimate? If so, you should be really uncertain about your current parameter estimate.
So to get a distribution for
For
- Resample a query location
from the observed . - Sample
from the likelihood. - Update
. - Stop once
has converged; record the final value as one draw of .
Then, we end up with
So what does this have to do with martingales?
Martingales are sequences of random variables where the expected value of the next random variable, given the current random variable and some context, is the current random variable.
Let
Martingales are nice because, under certain conditions, Doob’s convergence theorems guarantee that the sequence will converge to a random variable with finite expectation.
The key insight is that the sequence
Let’s use the same linear model from before:
Here’s the observed data along with the true line
Running the resampling loop
Each trajectory converges to some final value
Now we’ll run the procedure on data that’s less informative about the true parameter.
By ‘less informative’ I mean the observed
Here’s the data from both runs on the same plot: the informative sample spans
The martingale trajectories tell the same story.
The informative run (blue) quickly settles into a tight band around the true
And the resulting posteriors make the difference clear: compared to the uninformative case, the informative case has a much tighter distribution that is also closer to the true value.
Same procedure, same true model, same noise level.
The only thing that changed is how informative the
Code for the example above is here.
Acknowledgements
Thank you to Gerardo for bringing this paper to my attention! Check out his paper where he uses the same martingale-based approach to quantify uncertainty when the model is a neural network.