Checking Fit Quality With residplot
Calder Engineering checks a straight-line fit by looking at what it got wrong: for each reading, the recorded value minus the value the line expected. Those leftovers are charted on their own, because a pattern in them means the straight line was the wrong shape. The sheet also flags the single worst-fitting reading, so the technician can go and look at it.
Task: Print the size of the largest leftover.
Input
The first line holds one integer n, the number of readings, where 2 <= n <= 1000. Then come n lines, each holding a reading's x and y separated by a single space, x first. Not every reading has the same x.
Output
One line, rounded to 2 decimal places. Fit the least-squares line predicting y from x, take each reading's recorded y minus the line's value at that x, and print the largest of those distances ignoring sign. A reading far below the line counts exactly as much as one equally far above it.
Example:
Input:
4
1 2
2 4
3 5
4 8
Output:
0.70
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in