Presentation is loading. Please wait.

Presentation is loading. Please wait.

y=a+bx Linear Regression: Method of Least Squares slope y intercept y

Similar presentations


Presentation on theme: "y=a+bx Linear Regression: Method of Least Squares slope y intercept y"— Presentation transcript:

1 y=a+bx Linear Regression: Method of Least Squares slope y intercept y
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 a b=tana x y

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,7]; 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 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

5 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:


Download ppt "y=a+bx Linear Regression: Method of Least Squares slope y intercept y"

Similar presentations


Ads by Google