Presentation is loading. Please wait.

Presentation is loading. Please wait.

Physics 114: Lecture 14 Linear Fitting

Similar presentations


Presentation on theme: "Physics 114: Lecture 14 Linear Fitting"— Presentation transcript:

1 Physics 114: Lecture 14 Linear Fitting
John Federici NJIT Physics Department

2 New Jersey Trivia Which of the following inventions/ discoveries were NOT made at Bell Laboratories? Discovery of cosmic microwave background radiation – Evidence of the Big Bang Invention of the Transistor Cooling and Trapping of atoms using laser light Invention of CCD (charge –coupled device) semiconductor imaging sensors The telephone Unix computer operating system Electron Diffraction which demonstrated wave nature of matter The programming languages C and C++

3 New Jersey Trivia Which of the following inventions/ discoveries were NOT made at Bell Laboratories? The telephone – Alexander Graham Bell’s invention which started AT&T.

4 Least Squares Fit to a Straight Line
There are many situations where we can measure one quantity (the dependent variable) with respect to another quantity (the independent variable). For instance, we might measure the position of a car vs. time, where the position is the dependent variable and time the independent variable. If the velocity is constant, we expect a straight line Let us generically call the dependent variable y for this discussion, and the independent variable x. Then we can write such a linear relationship as , where a and b are constants. Here is a plot of points with noise, showing a linear relationship, and a straight line that goes through the points.

5 Least Squares Fit to a Straight Line
Here are several plots with lines through the points. Which one do you think is the best fit? It is surprisingly easy to see by eye which one fits best, but what does your brain do to determine this? It is minimizing c2! Let’s go through the problem analytically.

6 Minimizing Chi-Square
We start with a smooth line of the form which is the “curve” we want to fit to the data. The chi-square for this situation is To minimize any function, you know that you should take the derivative and set it to zero. But take the derivative with respect to what? Obviously, we want to find constants a and b that minimize , so we will form two equations:

7 Minimizing Chi-Square
Now we can rearrange these two equations to obtain two equations in two unknowns (a and b): You can solve this set of simultaneous equations any way you wish. One way is to use Cramer’s Rule of matrix theory, which says Ratios of determinants.

8 Alternative Math Solution
Inverse Matrix Identity Matrix

9 Linear Regression The solution, then, is where
Note that if the errors are all equal (i.e ), then when you take the ratio of these determinants the errors cancel and we get simpler expressions NOTE: these equations can be shown to be the SAME as given in OPENSTAX textbook page 681.

10 In Class Exercise Find the linear fit (y=a+xb) to the experimental data listed in the syllabus for this weeks lectures. What is the best fit a and b? What is the value of χ2? Plot on the same graph the experimental data as data points and the BEST FIT to the data as a straight line. For this exercise, do NOT use Matlabs built-in fitting functions. Instead SUM the vectors using the SUM function.


Download ppt "Physics 114: Lecture 14 Linear Fitting"

Similar presentations


Ads by Google