Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best...

33
Atomic Lab Atomic Lab Introduction to Error Introduction to Error Analysis Analysis

Transcript of Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best...

Page 1: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Atomic LabAtomic Lab

Introduction to Error AnalysisIntroduction to Error Analysis

Page 2: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Significant FiguresSignificant Figures For any quantity, x, the best measurement of x is For any quantity, x, the best measurement of x is

defined as xdefined as xbestbest ±±xx In an introductory lab, In an introductory lab, x is rounded to 1 x is rounded to 1

significant figuresignificant figure Example: Example: x=0.0235 -> x=0.0235 -> x=0.02 x=0.02

g= 9.82 ± 0.02g= 9.82 ± 0.02 Right and WrongRight and Wrong

Wrong: speed of sound= 332.8 ± 10 m/sWrong: speed of sound= 332.8 ± 10 m/s Right: speed of sound= 330 ± 10 m/sRight: speed of sound= 330 ± 10 m/s

Always keep significant figures throughout Always keep significant figures throughout calculation, otherwise rounding errors introducedcalculation, otherwise rounding errors introduced

Page 3: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Statistically the SameStatistically the Same

Student A = 30 Student A = 30 ± 2± 2Student B = 34 ± 5Student B = 34 ± 5Since the uncertainties for A & B overlap, Since the uncertainties for A & B overlap,

these numbers are statistically the samethese numbers are statistically the same

Page 4: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

PrecisionPrecision

Mathematical DefinitionMathematical Definition

Precision of speed of sound= 10/330 ~ 0.33 or Precision of speed of sound= 10/330 ~ 0.33 or 33%33%

So often we write: speed of sound= 330 So often we write: speed of sound= 330 ± 33%± 33%

bestx

xprecision

Page 5: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Propagation of Uncertainties– Propagation of Uncertainties– Sums & DifferencesSums & Differences

Suppose that x, …, w are independent Suppose that x, …, w are independent measurements with uncertainties measurements with uncertainties x, …, x, …, w w and you need to calculate and you need to calculate

q= x+…+z-(u+….+w)q= x+…+z-(u+….+w)

If the uncertainties are independent i.e. If the uncertainties are independent i.e. w is not w is not sum function of sum function of x etc then x etc then

Note: Note: q < q < x+…+ x+…+ z+ z+ u+…+ u+…+ ww

2222 wuzxq

Page 6: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Propagation of Uncertainties– Propagation of Uncertainties– Products and QuotientsProducts and Quotients

Suppose that x, …, w are independent Suppose that x, …, w are independent measurements with uncertainties measurements with uncertainties x, …, x, …, w and you w and you need to calculate need to calculate

If the uncertainties are independent i.e. If the uncertainties are independent i.e. w is not sum w is not sum function of function of x etc then x etc then

wu

zxq

2222

2222

w

w

u

u

z

z

x

xqq

or

w

w

u

u

z

z

x

x

q

q

Page 7: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Functions of 1 VariableFunctions of 1 Variable

xdx

dqq

Suppose Suppose = 20 = 20 ± 3 deg and want to find cos ± 3 deg and want to find cos 3 deg is 0.05 rad3 deg is 0.05 rad |(d(cos|(d(cos)/d)/d|=| -sin|=| -sin|= sin|= sin (cos(cos)= sin)= sin* * = sin(20 = sin(20oo)*(0.05))*(0.05) (cos(cos 20 20oo) = 0.02 rad and cos 20) = 0.02 rad and cos 20oo= 0.94= 0.94

So So coscos= 0.94 = 0.94 ± 0.02 ± 0.02

Page 8: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Power LawPower Law

Suppose q= xSuppose q= xnn and x and x ± ± xx

x

xn

q

q

Page 9: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Types of ErrorsTypes of Errors

Measure the period of a revolution of a Measure the period of a revolution of a wheelwheel

As we repeat measurements some will be As we repeat measurements some will be more or some lessmore or some less

These are called “random errors” These are called “random errors” In this case, caused by reaction timeIn this case, caused by reaction time

Page 10: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

What if the clock is slow?What if the clock is slow?

We would never know if our clock is slow; we We would never know if our clock is slow; we would have to compare to another clockwould have to compare to another clock

This is a “systematic error”This is a “systematic error”

In some cases, there is not a clear difference In some cases, there is not a clear difference between random and systematic errorsbetween random and systematic errors Consider parallax:Consider parallax:

Move head around: random errorMove head around: random error Keep head in 1 place: systematicKeep head in 1 place: systematic

Page 11: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Mean (or average)Mean (or average)

N

xx

N

xxxx

N

ii

N

1

21

Page 12: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

DeviationDeviation

ii xxd Need to calculate an average or “standard” deviation

To eliminate the possibility of a zero deviation, we square di

11

2

N

dN

ii

x

When you divide by N-1, it is called the population standard deviation

If dividing by N, the sample standard deviation

Page 13: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Standard Deviation of the MeanStandard Deviation of the Mean

The uncertainty in the best measurement is given by the standard deviation of the mean (SDOM)

N

N

d

xx

N

ii

x

11

2If the xbest = the mean, then best =mean

Page 14: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

HistogramsHistograms

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

1 2 3 4 5 6

Value

Number of times that value has occurred

Page 15: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Distribution of a Craps GameDistribution of a Craps Game

Histogram

05

101520253035404550

2 3 4 5 6 7 8 9

10

11

12

Mo

re

Bin

Fre

qu

en

cy

Bell CurveOr Normal Distribution

Page 16: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Bell CurveBell Curve

0

50

100

150

200

250

300

350

400

0 2 4 6 8 10 12 14

Dice Value

Fre

qu

ency

Dice

Gaussian

Centroid or Mean

x- x+

68 %

Between x-2 to x+2, 95% of population2 is usually defined as Error

Page 17: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

GaussianGaussian

0

50

100

150

200

250

300

350

400

0 2 4 6 8 10 12 14

Dice Value

Freq

uenc

y

Dice

Gaussian

X0

2

20

2* x

xx

eAGaussian

In the Gaussian, x0 is the mean and x is the standard deviation.

They are mathematically equivalent to formulae shown earlier

Page 18: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Error and UncertaintyError and Uncertainty

While definitions vary between scientists, While definitions vary between scientists, most would agree to the following most would agree to the following definitionsdefinitions

Uncertainty of measurement is the value Uncertainty of measurement is the value of the standard deviation (1 of the standard deviation (1 ))

Error of the measurement is the value of Error of the measurement is the value of two times the standard deviation (2 two times the standard deviation (2 ))

Page 19: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Full Width at Half MaximumFull Width at Half Maximum

A special quantity is the full width at half A special quantity is the full width at half maximum (FWHM)maximum (FWHM) The FWHM is measured by taking ½ of the maximum The FWHM is measured by taking ½ of the maximum

value (usually at the centroid)value (usually at the centroid) The width of distribution is measured from the left side The width of distribution is measured from the left side

of the centroid at the point where the frequency is this of the centroid at the point where the frequency is this half valuehalf value

It is measured to the corresponding value on the right It is measured to the corresponding value on the right side of the centroid. side of the centroid.

Mathematically, the FWHM is related to the Mathematically, the FWHM is related to the standard deviation by FWHM=2.354*standard deviation by FWHM=2.354*xx

Page 20: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Weighted AverageWeighted Average

Suppose each measurement has a unique Suppose each measurement has a unique uncertainty such as uncertainty such as

xx11 ± ± 11

xx22 ± ± 22

……

xxNN ± ± NN

What is the best value of x?What is the best value of x?

Page 21: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

We need to construct statistical We need to construct statistical weightsweights

We desire that measurements with small errors We desire that measurements with small errors have the largest influence and the ones with the have the largest influence and the ones with the largest errors have very little influencelargest errors have very little influence

Let w=weight= 1/Let w=weight= 1/ii22

N

ii

N

iii

best

w

xwx

1

1

*

This formula can be used to determine the centroid of a Gaussian where the weights are the values of the frequency for each measurement

N

ii

x

wbest

1

1

Page 22: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Least Squares FittingLeast Squares Fitting

What if you want to fit a straight line What if you want to fit a straight line through your data?through your data?

In other words, yIn other words, yii = A*x = A*xii + B + BFirst, you need to calculate residualsFirst, you need to calculate residualsResidual= Data – Fit orResidual= Data – Fit orResidual= yResidual= yii – (A*x – (A*xii+B)+B)When as the Fit approaches the Data, the When as the Fit approaches the Data, the

residuals should be very small (or zero). residuals should be very small (or zero).

Page 23: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Big ProblemBig Problem

Some residuals >0Some residuals >0Some residuals <0Some residuals <0 If there is no bias, then rIf there is no bias, then rjj = -r = -rkk and then r and then rjj

+ r+ rkk =0 =0

The way to correct this is to square rThe way to correct this is to square r jj and and

rrk k and then the sum of the squares is and then the sum of the squares is

positive and greater than 0positive and greater than 0

Page 24: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Chi-square, Chi-square, 22

N

i i

ii BxAy

1

2

2

We need to minimize this function with respect to A and B soWe take the partial derivative of w.r.t. these variables and set the resulting derivatives equal to 0

0

0

1

22

1

22

N

i i

ii

N

i i

ii

BxAy

BB

BxAy

AA

Page 25: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Chi-square, Chi-square, 22

NBxAy

xBxAyx

NBB

BxAyBxAy

xBxAyxxBxAyx

BxAyBxAy

BB

xBxAyBxAy

AA

N

ii

N

ii

N

ii

N

ii

N

iii

N

i

N

i

N

ii

N

ii

N

iii

N

ii

N

ii

N

iii

N

iiiii

N

iii

i

N

i i

ii

N

iiii

i

N

i i

ii

11

11

2

1

1

1111

2

11

2

11

2

12

1

22

12

1

22

0

0

02

02

Page 26: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Using DeterminantsUsing Determinants

N

ii

N

ii

N

iii

N

ii

N

ii

N

ii

N

iii

N

ii

N

ii

N

ii

N

ii

N

ii

N

ii

N

ii

N

iii

yx

yxx

B

Ny

xyx

ANx

xx

NBxAy

xBxAyx

11

11

2

1

11

1

11

2

11

11

2

1

Page 27: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

A PseudocodeA PseudocodeDim x(100), y(100)Dim x(100), y(100)xsum=0xsum=0x2sum=0x2sum=0Xysum=0Xysum=0N=100N=100Ysum=0Ysum=0For i=1 to 100For i=1 to 100

xsum=xsum+x(i)xsum=xsum+x(i) ysum=ysum+y(i)ysum=ysum+y(i)

xysum=xysum+x(i)*y(i)xysum=xysum+x(i)*y(i)x2sum=x2sum+x(i)*x(i)x2sum=x2sum+x(i)*x(i)

Next INext IDelta= N*x2sum-(xsum*xsum)Delta= N*x2sum-(xsum*xsum)A=(N*xysum-xsum*ysum)/DeltaA=(N*xysum-xsum*ysum)/DeltaB=(x2sum*ysum-xsum*xysum)/DeltaB=(x2sum*ysum-xsum*xysum)/Delta

Page 28: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

2 2 ValuesValues

If calculated properly, If calculated properly, 2 2 start at large values andstart at large values and

approach 1approach 1 This is because the residual at a given point should This is because the residual at a given point should

approach the value of the uncertaintyapproach the value of the uncertainty Your best fit is the values of A and B which give Your best fit is the values of A and B which give

the lowest the lowest 22

What if What if 22 is less than 1?! is less than 1?! Your solution is over determined i.e. a larger number Your solution is over determined i.e. a larger number

of degrees of freedom than the number of data pointsof degrees of freedom than the number of data points Now you must change A and B until the Now you must change A and B until the 2 2 doesn’t doesn’t

vary too muchvary too much

Page 29: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Without ProofWithout Proof

N

iy

B

i

N

iy

A

i

i

N

x

1

2

2

1

2

2

Page 30: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Extending the MethodExtending the Method

Obviously, can be Obviously, can be expanded to larger expanded to larger polynomials i.e. polynomials i.e. Becomes a matrix Becomes a matrix

inversion probleminversion problem

Exponential FunctionsExponential Functions Linearize by taking Linearize by taking

logarithmlogarithm Solve as straight lineSolve as straight line

N

i i

iii CxBxAy

1

222

tAtA

eAtA t

0

0

ln)(ln

)(

Page 31: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Extending the MethodExtending the Method

Power LawPower Law

Multivariate Multivariate multiplicative multiplicative functionfunction

tAEfficiency

tAEfficiency

AxNI

AxI N

loglogloglog

logloglog

Page 32: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Uglier FunctionsUglier Functions

q=f(x,y,z)q=f(x,y,z) Use a gradient search Use a gradient search

methodmethod Gradient is a vector Gradient is a vector

which points in the which points in the direction of steepest direction of steepest ascentascent

f = a direction f = a direction So follow So follow f until it f until it

hits a minimumhits a minimum

zz

yy

xx

Page 33: Atomic Lab Introduction to Error Analysis. Significant Figures For any quantity, x, the best measurement of x is defined as x best ±  x For any quantity,

Correlation Coefficient, rCorrelation Coefficient, r22

2

11

2

2

11

2

1112

N

ii

N

ii

N

ii

N

ii

N

ii

N

ii

N

iii

yyNxxN

yxyxNr

rr22 starts at 0 and approaches 1 as fit gets better starts at 0 and approaches 1 as fit gets better rr22 shows the correlation of x and y … i.e. is shows the correlation of x and y … i.e. is

y=f(x)?y=f(x)? If rIf r22 <0.5 then there is no correlation. <0.5 then there is no correlation.