CITS2401 Computer Analysis & Visualisation

Slides:



Advertisements
Similar presentations
Splines and Piecewise Interpolation
Advertisements

AP Statistics Section 3.2 C Coefficient of Determination
1 Chapter 13 Curve Fitting and Correlation This chapter will be concerned primarily with two separate but closely interrelated processes: (1) the fitting.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
Chapter 15 Above: GPS time series from southern California after removing several curve fits to the data.
©1999 BG Mobasseri 15/24/99 INTERPOLATION AND CURVE FITTING Etter: pp June 16, ‘99.
Chapter 18 Interpolation The Islamic University of Gaza
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Lecture 11 Chap. 15. Outline Interpolation – Linear Interpolation – Cubic Spline Interpolation – Extrapolation 15.2 Curve.
Regression Regression: Mathematical method for determining the best equation that reproduces a data set Linear Regression: Regression method applied with.
Curve Fitting and Interpolation: Lecture (IV)
Least Square Regression
Least Square Regression
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 17 Least Square Regression.
Part 4 Chapter 13 Linear Regression
Probability & Statistics for Engineers & Scientists, by Walpole, Myers, Myers & Ye ~ Chapter 11 Notes Class notes for ISE 201 San Jose State University.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 24 Regression Analysis-Chapter 17.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 171 CURVE.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 171 Least.
Introduction  Today we are looking at how to interpret experimental data  Normally, data is acquired with random errors  How do we take the data and.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Curve Fitting ~ Least Squares Regression Chapter.
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Chapter 13 Statistics © 2008 Pearson Addison-Wesley. All rights reserved.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
AP STATISTICS LESSON 3 – 3 LEAST – SQUARES REGRESSION.
Recap Summary of Chapter 6 Interpolation Linear Interpolation.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
Polynomial Interpolation You will frequently have occasions to estimate intermediate values between precise data points. The function you use to interpolate.
Chapter 8 Curve Fitting.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
ES 240: Scientific and Engineering Computation. Chapter 13: Linear Regression 13. 1: Statistical Review Uchechukwu Ofoegbu Temple University.
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
Computers in Civil Engineering 53:081 Spring 2003 Lecture #15 Spline Interpolation.
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
MODEL FITTING jiangyushan. Introduction The goal of model fitting is to choose values for the parameters in a function to best describe a set of data.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 15 General Least Squares and Non- Linear.
Principles of Extrapolation
Chapter 13 Objectives Familiarizing yourself with some basic descriptive statistics and the normal distribution. Knowing how to compute the slope and intercept.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 13.1 Interpolation between.
Copyright © Cengage Learning. All rights reserved. 8 9 Correlation and Regression.
Interpolation - Introduction
Lecture 29: Modeling Data. Data Modeling Interpolate between data points, using either linear or cubic spline models Model a set of data points as a polynomial.
MATLAB for Engineers 3E, by Holly Moore. © 2011 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Matlab Training Session 11: Nonlinear Curve Fitting
Copyright © Cengage Learning. All rights reserved.
Introduction to Programming for Mechanical Engineers
Part 5 - Chapter
Part 5 - Chapter 17.
EEE 244-7: Curve Fitting.
S519: Evaluation of Information Systems
Lecture 10 2D plotting & curve fitting
Chapter 12 Curve Fitting : Fitting a Straight Line Gab-Byung Chae
Part 5 - Chapter 17.
MATH 2140 Numerical Methods
Section 3.3 Linear Regression
Linear regression Fitting a straight line to observations.
Least Squares Fitting A mathematical procedure for finding the best-fitting curve to a given set of points by minimizing the sum of the squares of the.
Splines and Piecewise Interpolation
Interpolation and curve fitting
Least-Squares Regression
Least Square Regression
SKTN 2393 Numerical Methods for Nuclear Engineers
Presentation transcript:

CITS2401 Computer Analysis & Visualisation Faculty of engineering, computing and mathematics CITS2401 Computer Analysis & Visualisation School of Computer Science and Software Engineering Topic 10 Curve Fitting Material from MATLAB for Engineers, Moore, Chapters 13 Additional material by Peter Kovesi and Wei Liu

In this lecture we will interpolate between data points, using either linear or cubic spline models model a set of data points as a polynomial use the basic fitting tool

Interpolation When you take data, how do you predict what other data points might be? Two techniques are : Linear Interpolation Assume data follows a straight line between adjacent measurements Cubic Spline Interpolation Fit a piecewise 3rd degree polynomial to the data points to give a “smooth” curve to describe the data.

What is the corresponding value of y for this x?

Linear Interpolation How do you find a point in between? X=2, Y=? Assume the function between two points is a straight line

Interpolated Points Interpolated Point Linear Interpolation – Connect the points with a straight line to find y

MATLAB Code interp1 is the MATLAB function for linear interpolation First define an array of x and y Now define a new x array, that includes the x values for which you want to find y values new_y=interp1(x,y,x_new) Exercise: How would you implement the interp1 function yourself? What control structures would you use?

Both measured data points and interpolated data were plotted on the same graph. The original points were modified in the interactive plotting function to make them solid circles.

Cubic Spline Interpolation A cubic spline creates a smooth curve, using a third degree polynomial. The curve does not correspond to a single cubic. Instead it is a set of cubic polynomials that meet at the measured data points. In fact, the polynomials are continuous up to their 2nd derivative. Finding these polynomials can be reduced to the problem of solving a set of simultaneous linear equations, (but this is beyond the scope of this unit). Note, that all the original points remain on the curve.

We can get an improved estimate by using the spline interpolation technique

Cubic Spline Interpolation Cubic Spline Interpolation. The data points on the smooth curve were calculated. The data points on the straight line segments were measured. Note that every measured point also falls on the curved line.

Other Interpolation Techniques MATLAB includes other interpolation techniques including Nearest Neighbor Cubic Two dimensional Three dimensional Use the help function to find out more if you are interested

Curve Fitting There is scatter in all collected data. We can estimate the equation that represents the data by “eyeballing” a graph. There will be points that do not fall on the line we estimate. Curve fitting is used when we want to match an analytical (or symbolic) model to a set of measurements which may contain some error. Interpolation is used when we assume that all data points are accurate and we would like to infer new intermediate data points.

This line is just an “eyeballed guess”

Least Squares Finds the “best fit” straight line Minimizes the amount each point is away from the line It’s possible none of the points will fall on the line Linear Regression is used to define the line that minimizes the square of the errors (the distance each point is from the value predicted by the line). The same method is used by the slope function in Excel.

Polynomial Regression Linear Regression finds a straight line, which is a first order polynomial If the data doesn’t represent a straight line, a polynomial of higher order may be a better fit In MATLAB you do both linear and polynomial regression the same way – the only difference is the order

polyfit and polyval polyfit finds the coefficients of a polynomial representing the data Coef = polyfit(x,y,2); will set coef = [a,b,c] where a*x2+b*x+c is the quadratic that minimizes the square of the error. polyval uses those coefficients to find new values of y, that correspond to the known values of x newy = polyval(coef,X) will evaluate the polynomial corresponding to coef for each point in X and return the corresponding y-values. The degree of the polynomial is determined by the length of coef.

Coefficients of the first order polynomial describing the best fit line Evaluate how close a fit you’ve achieved by taking the difference between the measured and calculated points

Least Squares Fit The polyfit function minimizes this number

Second Order Fit

A fifth order polynomial gives a perfect fit to 6 points

Improve your graph by adding more points

An example from the labs We can read in the Excel file from Lab 2 using the xlsread function: data = xlsread('Rings.xls'); We can extract X and Y arrays and find the line of best fit: X = X(2:78); Y = Y(2:78); coef = polyfit(X,Y,1); NewY = polyval(coef,X)

Using the Interactive Curve Fitting Tools MATLAB 7 includes new interactive plotting tools. They allow you to annotate your plots, without using the command window. They include basic curve fitting, more complicated curve fitting statistical tools

Use the curve fitting tools… Create a graph Making sure that the figure window is the active window select Tools-> Basic Fitting The basic fitting window will open on top of the plot

Plot generated using the Basic Fitting Window

Residuals are the difference between the actual and calculated data points

Basic Fitting Window

You can also access the data statistics window from the figure menu bar. Select Tools->Data Statistics from the figure window. This window allows you to calculate statistical functions interactively, such as mean and standard deviation, based on the data in the figure, and allows you to save the results to the workspace. Data Statistics Window

Matlab Review This completes the section of the unit covering Matlab There is a great deal of Matlab functionality available, but you should be aware of the basics: How data is represented using arrays and matrices How variables are created and modified How functions are defined and used How conditions (if), loops (for, while), matrix operations, and IO can be combined to define a process. How to plot and visualize data.