Signal fitting

Lecture 4: mostly about model fitting.
The parent function –
what we’d like to
find out (but never can,
exactly).
• The model is our
estimate of the parent
function.
• Let’s express the
model m(xi) as a
function of a few
parameters θ1, θ2 .. θP
• Finding the ‘best fit’
model then just
means best estimates
of the θ. (Bold – shorthand for a list)
• Knowledge of physics
informs choice of θ.
NASSP Masters 5003F - Computational Astronomy - 2009
Naive best fit calculation:
• Want to minimize all the deviates |yi-mi|.
• A reasonable single number to minimize is:
• But what if some bits have larger σ than others?
– Answer: weight by 1/σ2i – just like the best-SNR
weighted average:
• This is sometimes (a bit deceptively) known as
the chi squared (χ2) formula.
• Choose θ which minimizes U.
NASSP Masters 5003F - Computational Astronomy - 2009
Simple example: mi = θ1 + θ2si
Model – red is si, green the flat background.
Map of U.
The data yi:
NASSP Masters 5003F - Computational Astronomy - 2009
χ2 remarks
• Sometimes known as the ‘method of least
squares’.
• Have ignored possibility that xi might also
have errors.
• Concept of degrees of freedom ν:
– The higher the number P of parameters, the
better the model fits the noise, therefore the
lower the average (yi-mi)2.
– Normalize by ν = N – P.
•
• Should ~1.
Reduced χ2:
NASSP Masters 5003F - Computational Astronomy - 2009
How good is the fit?
• χ2 for the parent function has a probability
distribution
• Probability of χ2 equalling U or higher is

1
 U 
t 
P   U ,  Q ,  
dt
e
t

 2 2   2 U 2

2

21
• Equals: probability that the data come
from the model.
• But… is U truly distributed as χ2?
– If in doubt, check with a Monte Carlo!
NASSP Masters 5003F - Computational Astronomy - 2009
χ2 for Poisson data
• Choose data yi as estimator for σi2?
– Can have zero values in denominator.
• Choose (evolving) model as estimator for
σi2?
– Gives a biased result.
• Better: Mighell formula
• Unbiased, but no good for goodness-of-fit.
– Use Mighell to fit θ then standard U for
“goodness of fit” (GOF).
NASSP Masters 5003F - Computational Astronomy - 2009
Likelihood
• Take, for example, a single datum y which is a
parent function f + gaussian noise. IF m = f,
• But, can also think of this as the ‘probability’ of m
given y, p(m|y). (Then no worry about the ‘if’.)
• Comments on p(m|y):
– May not be true;
• hence, Bayesian use of any extra prior information.
– Hard to check.
– However, the flow of information seems right: ie, from
known (the data) towards unknown but desired (the
model).
• Known as the likelihood of m given y.
NASSP Masters 5003F - Computational Astronomy - 2009
Even simpler example: m = θ
For Poissonian noise this time (because it
is more interesting, and harder to handle
with ‘traditional’ χ2):
Probability p(y|θ) = θy e–θ / y!
Likelihood p(θ|y) = θy e–θ / y!
NASSP Masters 5003F - Computational Astronomy - 2009
Likelihood continued.
• We can use likelihood to calculate the best-fit θ.
• If we have several data values y=[y1,y2…yN],
multiply the separate likelihoods together:
• It’s often easier if we take logs:
NASSP Masters 5003F - Computational Astronomy - 2009
Likelihood continued.
• Back to 2-parameter model mi = θ1 + θ2si
of slide 3, but now with Poissonian noise.
• Minimize L same as U to get optimum θ.
• Can ignore the Σln(yi!) term because it
doesn’t depend on any θ.
• p(θ1,θ2|y) is an example of a joint
probability distribution, in this case a
bivariate one because there’s only 2
parameters.
NASSP Masters 5003F - Computational Astronomy - 2009
Poissonian/likelihood version of slide 3
Model – red is si, green the flat background.
Map of the joint likelihood L.
The data yi:
NASSP Masters 5003F - Computational Astronomy - 2009
Likelihood continued.
• An interesting fact:
– Maximum likelihood for gaussian data leads
to the U (ie, ‘χ2’) expression!
NASSP Masters 5003F - Computational Astronomy - 2009