lecture 20: intro to fitting, least squaresbelz/phys3730/lab20/lecture20.pdf · lecture 20: intro...

16
Lecture 20: Intro to Fitting, Least Squares Physics 3730/6720 Fall Semester 2019 A bunch of fittings

Upload: others

Post on 31-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Lecture 20: Intro to Fitting,Least Squares

Physics 3730/6720Fall Semester 2019

A bunch of fittings

Page 2: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Fitting● Purpose: Compare data

to a physical model.● “Model” (Webster) – a

system of postulates, data, and inferences presented as a mathematical description of an entity or state of affairs

● i.e. a functional relationship between variables

Page 3: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Fitting● Simplest case: straight line fit

to data with normally distributed (Gaussian) uncertainties.

● What does this mean?

– Measure quantity x, N times.

– As N → large, parent probability distribution → Gaussian

Page 4: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Gaussian Errors● Note that one

sigma (1s)error interval is not the maximum possible excursion from X

0:

– 32% > 1s

– 4.5% > 2s

– 0.27% > 3s

Page 5: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Use “2/3rds Rule” as a Rough Guide

● Spread of points, error bars consistent with normal error distribution.

s6

s5

s4

s3

s2

s1

Independent variable(assume uncertainty negligible)

dependent

vari

able

Page 6: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

● What is the problem here?

Use “2/3rds Rule” as a Rough Guide

Page 7: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

● What is the problem here?

Use “2/3rds Rule” as a Rough Guide

Page 8: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Problem of Straight-Line Fitting● Remaining problem: I have a set of points

(x

i,y

i ± s

i)

which I expect to follow a linear relationship y = A + Bx What is my best estimate for the coefficients A, B?

Page 9: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

1st: Mechanical Analog● Suppose we have a set of

points (xi,y

i).

Page 10: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

1st: Mechanical Analog● Suppose we have a set of

points (xi,y

i).

● To each point, connect a spring. (Imagine spring can only move in y direction.)

Page 11: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

1st: Mechanical Analog● Suppose we have a set of

points (xi,y

i).

● To each point, connect a spring. (Imagine spring can only move in y direction.)

● To the other end of the springs attach a rigid rod.

Page 12: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

1st: Mechanical Analog● Suppose we have a set of

points (xi,y

i).

● To each point, connect a spring. (Imagine spring can only move in y direction.)

● To the other end of the springs attach a rigid rod.

● What will determine where rod comes to rest?

Page 13: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

1st: Mechanical Analog● Suppose we have a set of

points (xi,y

i).

● To each point, connect a spring. (Imagine spring can only move in y direction.)

● To the other end of the springs attach a rigid rod.

● Equilibrium position of rod will minimize potential energy.

Page 14: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

replace

With the “chi-squared”

function:

thus replace

The problem of fitting data with normally distributeduncertainties is reduced to a matter of finding the model parameters that minimize the chi-squared.

Page 15: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Chi-squared Minimization

● Today: Do chi-squared minimization by brute-force search of parameter space.

● Thursday/Homework: Look at general analytic (but computation-heavy) solution for “linear functions” of the form:

y = a0 + a

1x1 +a

2x2 + a

3x3 + ...

Page 16: Lecture 20: Intro to Fitting, Least Squaresbelz/phys3730/lab20/lecture20.pdf · Lecture 20: Intro to Fitting, Least Squares ... The problem of fitting data with normally distributed

Additional Reading:

Taylor: An Introduction to Error Analysis

Bevington: Data Reduction and Error Analysis for the Physical Sciences

Press et al, Numerical Recipes