Hello I have this question to do which I'm finding it really hard basically:

I have to write a program to perform a least-squares analysis (also called linear regression) of the data shown below this page, and find the line of best-fit relating log velocity to magnitude. They have given me a start to this: which is shown in the attachment along with the data given.

I calculated sumx, sum y, sumxx, and sumxy and inputted it into the program...but it was telling me to declare variables:

j, m, nd, gradient, intercept, logvel

so i declared j, m and nd to int and the others to a float...But it said that incorrect value or array. Clearly i'm missing a lot of code, but I just dont know how to go from here, if anyone can help i would really appreciate it,!

Thanks a lot for your time

From Steve