 Hello and welcome to this session. In this session, we will discuss how to fit a linear function by method of least squares also known as regression line y on x and we will show problems in this context of data. Now in level 2, we have discussed about line of best fit by n i. The problem with bad fit of line is that it will vary from person to person. So to avoid this problem, the method of linear regression is used to fit the equation of the line that best fits the data. Now suppose we have an bivariate data whose scatter plot is this. Now here we have fitted a line. Now see all the points do not lie on this line. They are points which are at some distance from this line. Now see this point. This point is not lying on this line. Now here we have drawn a vertical line from this point to this line of fit. So this value of y for the given value of x is observed value given in the data and this value of y on the line for the given value of x is predicted value denoted by y hat and this distance between these three values is d which is equal to y minus y hat and this distance is also known as error or residual denoted by r i. Now again from these two points we have drawn vertical lines to the line of fit. So let this distance that is this vertical distance from this point to this line of fit be d1 and similarly let this distance be d2. Now let us square these distances and find the sum. So it will be d1 square plus d2 square plus d3 square plus so on. Now if all the points are close to the line then this value will be small. Now the least square regression line is the line which minimizes this value. Thus the regression describes the relationship between two variables in the situation where one variable can be used to predict the other variable and the regression line is a straight line that describes how response variable y changes when there is a change in explanation variable x. Now let us discuss regression equation y on x. Now suppose we have given y review data x1, y1, x2, y2, x3, y3 and so on. Then regression equation y on x is given by y hat is equal to a plus bx where b is the slope or regression coefficient y on x that is given by r into sy upon fx and intersect a is equal to y bar minus b into x bar where r is the regression coefficient sy is standard deviation of y, fx is standard deviation of x and y bar is mean of y, x bar is mean of x. And we can use the following formula directly for finding the regression coefficient y on x that is b is equal to summation of xy minus n into x bar into y bar when upon summation of x square minus n into x bar square. Note that least square regression line always passes through the point x bar y bar that is the mean. Now consider the following example. Here the connection between the size and price of pizza is given on the table, here the size is given in inches and price is given in dollars. Now that this is happening in 8 art we have to draw the scatter plot in v art we have to determine the regression line and third part is using this data how much would you expect to pay for a pizza of size 20 inches. Now let y be the price be the size of pizza. Now let us make its scatter plot now on x axis we have taken the size and on y axis we have taken the price. Now the first point that we have to plot is given by the audit pair 6 3 so here this is the point with coordinates 6 3 then the next point is given by the audit pair 8 5 here is the point with coordinates 8 5 then the next audit pair is 12 8 so this is the point with coordinates 12 8 lastly we have to draw the point with coordinates 16 10 so here is the point with coordinates 16 10 so this is the required plot for this given data. Now we have to find regression line y on x now we know that regression line y on x is given by y hat is equal to a plus b x so we have to find the values of a and b for this first of all we have to find the values of x bar and y bar now we know that x bar that is mean of x is equal to summation of x upon n where m is the number of observations and here every value of x is given to us in the data we have 6 plus 8 plus 12 plus 16 that is equal to 42 so summation of x is equal to 42 and here you can see number of observations is equal to 1 2 3 and 4 so x bar is equal to summation x that is 42 upon m that is 4 so this is equal to 10.5 similarly y bar is equal to summation of y upon m while here as we want the values of y we have 3 plus 5 plus 8 plus 10 that is equal to 26 so summation of y is equal to 26 so y bar is equal to 26 upon 4 that is equal to 6.5 now we know this formula for finding the regression coefficient y on x now we have already calculated x bar and y bar here we have to calculate summation of x bar summation of x square so in this table we will make 2 more columns for finding the values of x bar x square. Firstly let us find the values of x bar now we have the x is equal to 6 y is equal to 3 as 6 into 3 is 18 here you can see 8 into 5 is 40 when 12 into 8 is 96 and 16 into 10 is 160 so we have calculated all the values of x y now we will add all these values and add all these values we got summation of x y is equal to 314 now let us find the values of x square now here x is equal to 6 so x square will be equal to 6 square that is equal to 36 when 8 square is equal to 64 then 12 square is equal to 144 and 16 square is equal to 256 now adding all the values of x square we got summation of x square is equal to 500 so we have got all these values now here we have x bar is equal to 10.5 so x bar square is equal to 10.5 square that is equal to 110.25 so putting all these values in this formula we have b is equal to summation of x y that is 314 minus n that is 4 into x bar that is 10.5 into y bar that is 6.5 whole upon summation of x square that is 500 minus n that is whole into x bar square that is 110.25 that is equal to 314 minus 273 whole upon 500 minus 441 further on calculating this is equal to 0.69 so regression coefficient y on x that is b is equal to 0.69 now we know that intersection a is equal to y bar minus b into x bar so by putting the values we get a is equal to minus 0.75 now putting the values of b and a and this equation of regression line y on x we get y hat is equal to minus 0.75 plus 0.69 into x now we have to find the price that is y when size x is equal to 20 so we put x is equal to 20 in this line of regression and we get y hat is equal to minus 0.75 plus 0.69 into 20 that is equal to minus 0.75 plus 13.8 and this is equal to 13.05 so when x is equal to 20 y is equal to 13.05 this means price will be 13.05 when size of pizza is 20 inches now regression coefficient indicates how much y hat that is predicted value of y changes for unit change in x if it is positive then the predicted value of y will increase with increase in x so in this fashion we have discussed how to fit a linear function by method of least squares and this for pizza session hope you all have enjoyed the session.