Data Points Within 4% of Best fit line algorithm

365 Views Asked by At

This question is actually based on a problem I am attempting to solve within a C program. I am attempting to understand how the mathmatical equation that would need to be writtne.

I will have 10 data points. I know ahead of time what the X value for each of these points will be. I have to calculate the value of the Y for each point. I believe I have everything I need to calculate the best fit line. My question isn't on how to calculate the best fit line itself.

The problem I have is that I need to verify that each data point is within 4% of the line itself. I won't actually be plotting the line itself, I believe each {X,Y} point of the best-fit line will need to be calcualte, to determine if my data points are within 4% I just don't know the equation to do that.

What is the equation?

The follow graphics are for illustration purposes only. I wasn't able to think of a best title for the question.

enter image description here

enter image description here

enter image description here

Image Source

1

There are 1 best solutions below

1
On

You have your original data points say [x(i),y(i)] and you have your model which, in ganeral manner write y = f[x]. So, for each value x(i), compute y_calc(i) = f[x(i)]. The difference [y_calc(i) - y(i)] is the absolute error and [y_calc(i) - y(i)] / y(i) is the relative error for data point (i). Check for each of the points this relative error (take its absolute value) is or not lower than 0.04.