OPSE 301: Lab13 Data Analysis – Fitting Data to Arbitrary Functions

Slides:



Advertisements
Similar presentations
Tutorial 3 Refractor assignment, Analysis, Modeling and Statics
Advertisements

The Basics of Physics with Calculus – Part II
Example 2.2 Estimating the Relationship between Price and Demand.
TI-84 Data Fitting Tutorial Prepared for Math Link Participants By Tony Peressini and Rick Meyer Modified for TI-84 / TI-84 Plus by Tom Anderson, Feb.
Least squares CS1114
Regression Analysis Once a linear relationship is defined, the independent variable can be used to forecast the dependent variable. Y ^ = bo + bX bo is.
Regression Analysis Using Excel. Econometrics Econometrics is simply the statistical analysis of economic phenomena Here, we just summarize some of the.
A Short Introduction to Curve Fitting and Regression by Brad Morantz
Section 4.2 Fitting Curves and Surfaces by Least Squares.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
x – independent variable (input)
Copyright (c) Bani K. Mallick1 STAT 651 Lecture #18.
RESEARCH STATISTICS Jobayer Hossain Larry Holmes, Jr November 6, 2008 Examining Relationship of Variables.
1 1 Slide © 2003 South-Western/Thomson Learning™ Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Spreadsheet Problem Solving
Chem. 31 – 2/18 Lecture. Announcements Turn in AP1.2 Quiz today Exam 1 coming up (1 week from next Monday) Today’s Lecture –Chapter 4 Material Calibration.
Least Squares Regression Line (LSRL)
Non-Linear Simultaneous Equations
Electronic Devices Ninth Edition Floyd Chapter 13.
Calibration & Curve Fitting
DISCLAIMER This guide is meant to walk you through the physical process of graphing and regression in Excel…. not to describe when and why you might want.
Physics 114: Lecture 15 Probability Tests & Linear Fitting Dale E. Gary NJIT Physics Department.
Chem. 31 – 9/23 Lecture Guest Lecture Dr. Roy Dixon.
Analytical vs. Numerical Minimization Each experimental data point, l, has an error, ε l, associated with it ‣ Difference between the experimentally measured.
Ch4 Describing Relationships Between Variables. Pressure.
?v=cqj5Qvxd5MO Linear and Quadratic Functions and Modeling.
Overview Theory Index of Refraction and Path Length Setup and Procedure Michelson Interferometer Filming the Pressure Gauge Results Analysis Sources of.
Processing Lab 3 – Header issues and trace editing Bryce Hutchinson Objectives: Fixing elevation issues Define an LMO function Pick first breaks Kill traces.
Wave superposition If two waves are in the same place at the same time they superpose. This means that their amplitudes add together vectorially Positively.
Course 6: Analyzing AVO/AVA Analysis. Use gassman’s equations to predict velocity Objective accurately predict changes in amplitude.
Physics 114: Lecture 18 Least Squares Fit to Arbitrary Functions Dale E. Gary NJIT Physics Department.
Regression Analysis in Microsoft Excel MS&T Physics 1135 and 2135 Labs.
ABE425 Engineering Measurement Systems Ordinary Least Squares (OLS) Fitting Dr. Tony E. Grift Dept. of Agricultural & Biological Engineering University.
Info Read SEGY Wavelet estimation New Project Correlate near offset far offset Display Well Tie Elog Strata Geoview Hampson-Russell References Create New.
Today’s Lecture Neural networks Training
Physics 114: Lecture 16 Least Squares Fit to Arbitrary Functions
Topics
John Federici NJIT Physics Department
Interference and Diffraction
Physics 114: Lecture 13 Probability Tests & Linear Fitting
Physics 114: Lecture 18 Least Squares Fit to 2D Data
Fitting Equations to Data
Statistical Data Analysis - Lecture /04/03
Electromagnetism lab project
Physics 114: Lecture 14 Linear Fitting
AC Circuits AC Current peak-to-peak and rms Capacitive Reactiance
Driven SHM k m Last time added damping. Got this kind of solution that oscillates due to initial conditions, but then decays. This is an important concept.
Let’s do a Bayesian analysis
Data Mining Lecture 11.
Physics 114: Lecture 6 Measuring Noise in Real Data
Regression and Residual Plots
PH 105 Labs Hints for New LA (1/2) Presented by: Prepared by: Di Fan.
Fitting Linear Functions to Data
Physics 114: Exam 2 Review Material from Weeks 7-11
The Least Squares Line Lesson 1.3.
Chapter 8 Part 2 Linear Regression
Chapter 12 Curve Fitting : Fitting a Straight Line Gab-Byung Chae
Physics 114: Lecture 14 Linear Fitting
Hypothesis testing and Estimation
Linear Model Selection and regularization
6.7 Practical Problems with Curve Fitting simple conceptual problems
The Basics of Physics with Calculus – Part II
CHAPTER 3 Describing Relationships
CHAPTER 3 Describing Relationships
CHAPTER 3 Describing Relationships
Driven SHM k m Last time added damping. Got this kind of solution that oscillates due to initial conditions, but then decays. This is an important concept.
CHAPTER 3 Describing Relationships
DeltaV Neural - Expert In Expert mode, the user can select the training parameters, recommend you use the defaults for most applications.
Chapter 3: Describing Relationships
Chapter 9 Excel Extension: Now You Try!
Presentation transcript:

OPSE 301: Lab13 Data Analysis – Fitting Data to Arbitrary Functions John F. Federici NJIT Physics Department

Star Wars jokes….

Philosophy For this class, we are focusing on using Matlab… USE THE FORCE …… the Curve Fitting App…. so the details of HOW the fit is done is not important. For Physics Majors, you learned HOW the fit is done in Phys 114.

What is the Point Prof. Federici? The point LUKE is that Matlab invokes an algorithm to search the parameter space for the set of parameters so that one MAXIMIZES the ‘goodness of the fit’ or equivalently minimizes the ERROR in the fit of the data to a theoretical function. In terms of statistical analysis, we use a ‘correlation coefficient’ R2 in Matlab to measure the ‘goodness’ of the fit. Values of R=1 is a perfect fit. Values of R significantly less then 1 indicate a ‘bad’ fit. You can also get a feeling for the ‘goodness’ of fit based on how closely the data points follow the theoretical curve. Let’s do a conceptual example.

Let’s look at a fit to a linear function 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 maximizing R the ‘goodness’ of the fit. So, now that you understand the basic concept, let’s implement it in MATLAB.

Example Lab 13 – Interferometry Light waves INTERFERE through PRINCIPLE OF SUPERPOSITION. The NET wave is the algebraic sum of the two individual waves. Depending on the phase relation between the waves (ie. whether the peaks and valleys line up or anti-align) one can achieve HIGH power output or LOW power input.

Experimental Setup PZT: lead (Pb) zirconia (Zr) Titanate (Ti) THICKNESS of PZT is proportional to the voltage applied to the PZT.

Experimental Setup Measured Light Intensity by Photo Detector Voltage applied to PZT

Experimental Setup Measured Light Intensity by Photo Detector Voltage applied to PZT

Analysis of data The NUMBER Of interference fringes which pass by the detector is related to HOW FAR the PZT stack moves. From the Data, the goal is to EXTRACT from the data HOW FAR does the Mirror on the PZT material move. Wavelength of the Light (use 650nm) We calculate N from the best fit parameter A1 Length of time that mirror moving

Why this functional form? Amplitude Offset Initial Phase Delay between two interfering beams

Why this functional form? Assume that Voltage on PZT is proportional to distance PZT moves For a RAMP voltage, VELOCITY V of mirror on PZT is constant

Glitches in the data Why are there glitches in the data?

Voltage proportional to Thickness of PZT – Position of Mirror Mirror moving Forward Mirror moving Backward Mirror moving Forward Mirror moving Forward Mirror moving Backward Time

Voltage proportional to Thickness of PZT – Position of Mirror Mirror moving Forward Mirror moving Backward Mirror moving Forward Mirror moving Forward Mirror moving Backward Time

Removing Data from Fitting Fit data ONLY when Mirror is moving at CONSTANT velocity in ONE direction!

Roughly what value of N should you get? 1 2 3 4 5 N~5 After you do a fit and calculate N, CHECK to see if it makes sense. If it DOES NOT, there is something wrong with the fit.

OK, Let’s get on with the fitting Everyone turn on their Laptops, Power up MATLAB, and type in the commands as I do to follow along. IMPORT DATA: The first step is to import your data from the EXCEL file which you created in class for Lab 13. For practice, use the data which I put on the COURSE web page within the syllabus for Week 9. Importing the data is SIMILAR to what you did in Week 1 Matlab assignment Download the Lab 13 data set from the web site, in text format. Use the IMPORT DATA tool to read the data into Matlab. Y The first column of data is the ‘Time’ data. The second column of data is the ‘Voltage’ data for channel 1 (Interferometer Output) The second column of data is the Voltage data for the applied voltage to the PZT. Let’s use Matlab to see how its done. Define time data as variable ‘time’. Define photodetector voltage (channel 1) as value ‘output’. Define voltage applied to PZT as variable ‘PZT’.

Importing Data

Importing data

Importing Data

CURVE FITTING TOOL Let’s fit the photodetector data. Open the curve fitting tool. Use the CURVE Fitting Tool with ‘Custom Equation’ to fit the data. Choose FIT OPTION METHOD to be NONLINEAR LEAST SQUARES fit. Choose x data to be “time” Choose y data to be “output” Choose CUSTOM EQUATION and type in the equation you will be using. a*sin(b*x+c)+d Click on AUTO FIT.. The function should then try to fit. You MIGHT GET an ERROR. Open up FIT OPTIONS

Curve Fitting Tool

Example How do you know that this fit is bad?

Example For your fitting parameters, you can change the upper and lower limit for the fitting parameter and also change your initial ‘guess’ as to the final answer. Sometimes when you do the fitting you need to provide a REASONABLE guess for the fitting parameter. Remember, MATLAB is searching parameter space for a minimum. You want to make sure that it finds a GLOBAL minimum and not just a localized minimum.

Adjusting Parameters One of the reasons that you get a poor fit is that the initial “guesses” of the fitting parameters are not close enough to the “real” values to get a good fit. Try changing putting in more realistic guesses. For example, the minimum and maximum values of the data are roughly 0.03 and 0.07 respectively. This means that the parameter a is approximately (0.07-0.03)/2=0.02. The parameter d represents a constant offset. From the data plot above, this is approximately 0.05. Edit the FIT OPTIONS, but using a starting point for a of 0.02 and d of 0.05. ReAPPLY the fit. Note that you STILL get a bad fit. This is because the initial guess of b is too far off. EDIT the fitting options again, but use a starting point of 6000 for parameter b. Note that the fit is MUCH better. Your new best fit should look like the following:

Adjusting Parameters

Editing Fit Parameters Does not fit Peaks well. Note that we can not quite fit the peaks of the experimental data. You will notice that while the data looks like a sine wave, there are “glitches” in that data near x=0.0033, x=0.0085, x=0.0135, and x=0.0185. We will get a better fit by EXCLUDING data outside of a specific x value range. In the Curve Fitting Tool window, choose the tab for “Tools…Exclude Outliers” or “Tools…Exclude by Rule” to limit the data to X<=0.004 and X>=0.008. The EXCLUDED data points should turn red and the data included in the fit are black. Finally, you can rescale the plot using “Tools…Axes Limits” tab.

Exclude by Rule

Excluding data Fits Peaks well. Best Fit Parameters Good FIT!