Formula to find b in y=mx+b

305 Views Asked by At

I am trying find the formula to find b in y=mx+b. I have a scatter plot with 10 values. I have found m using =(sxy - (sx * sy) / n) / (sxx - (sx)^2 /n). Now I need to find b. I have been looking everyplace I could think to but the best thing I found was this $b=\frac{\displaystyle\sum _{i=1} ^ny_i-b\sum_{i=1}^nx_i}{n}$, but I don't know what that means. Also, I know I can use built in functions, that misses the point. I also don't want to just take two points and figure our about where it goes.

 x    y
 9    9
 2    6
 9   81
 5   28
 8   65
 7   53
 5   27
10  100
 4   21
 4   17

m = 8.9844
2

There are 2 best solutions below

0
On BEST ANSWER

There is a typo.

$$b=\frac{\displaystyle\sum _{i=1} ^ny_i-m\sum_{i=1}^nx_i}{n}$$

Are you able to compute $b$ now?

0
On

The built in functions you refer to are using linear regression and least squares. This pdf gives a decent overview. For your case if you construct a matrix X = [1 9; 1 2;1 9; 1 5; 1 8; 1 7; 1 5; 1 10; 1 4; 1 4] and Y = [9;6;81;28;65;53;27;100;21;17] then b = (X'X)^-1*X'Y=[-15.9017; 8.9844] The first number is b, the second your m.