Download presentation
Presentation is loading. Please wait.
Published byΆκανθα Λαμπρόπουλος Modified over 5 years ago
1
y=a+bx Linear Regression: Method of Least Squares slope y intercept
The Method of Least Squares is a procedure to determine the best fit line to data; the proof uses simple calculus and linear algebra. The basic problem is to find the best fit straight line y = a + bx given that, for n ϵ {1,…,N}, the pairs (xn; yn) are observed. The form of the fitted curve is Sum of squares of errors slope y=a+bx y intercept
2
Example 1: Find a 1st order polynomial y=a+bx for the values given in the table.
-5 -2 2 4 7 3.5 a=1.188 b=0.484 y= x With Matlab: clc;clear x=[-5,2,4]; y=[-2,4,3.5]; p=polyfit(x,y,1) x1=-5:0.01:7; yx=polyval(p,x1); plot(x,y,'ro',x1,yx,'b') xlabel('x value') ylabel ('y value') Data point Fitted curve
3
Example 2: x y 200 3 230 5 240 8 270 10 290 y=a+bx y=200.13 + 8.82x
200 3 230 5 240 8 270 10 290 y=a+bx y= x clc;clear x=[0,3,5,8,10]; y=[200,230,240,270,290]; p=polyfit(x,y,1) x1=-1:0.01:12; yx=polyval(p,x1); plot(x,y,'ro',x1,yx,'b') xlabel('x value') ylabel ('y value') Data point Fitted curve
4
Example 3: Intercept Slope
Tensile tests were performed for a composite material having a crack in order to calculate the fracture toughness. Obtain a linear relationship between the breaking load F and crack length a. Method of Least Squares Slope Intercept
5
with Matlab: clc;clear x=[10,9.25,9.1,9.4,8.5];
y=[0.5,0.4,0.35,0.45,0.28]; p=polyfit(x,y,1) F=8:0.01:12; a=polyval(p,F); plot(x,y,'ro‘,F,a,'b') xlabel('x value') ylabel ('y value')
6
Example 4: The change in the interior temperature of an oven with respet to time is given in the Figure. It is desired to model the relationship between the temperature (T) and time (t) by a first order polynomial as T=c1t+c2. Determine the coefficients c1 and c2. T (°C) t (min.) 175 204 200 212 Slope Intercept
7
clc;clear x=[0,5,10,15]; y=[175,204,200,212]; p=polyfit(x,y,1) t=0:0.01:15; T=polyval(p,t); plot(x,y,'ro',t,T,'b') xlabel('x value') ylabel ('y value‘) with Matlab:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.