Showing Only the Fit Line, No Points
Calder Engineering overlays several fitted lines on one axis to compare batches, and with every batch's readings drawn as well the chart becomes unreadable, so the points are suppressed and only the lines remain. The sheet quotes where one batch's line sits at a load of zero -- its baseline reading before anything is applied.
Task: Print the intercept of the least-squares line predicting y from x.
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 holding the intercept, rounded to 2 decimal places. The intercept is the line's value where x is zero, not its tilt, and the line is the least-squares one predicting y from x.
Example:
Input:
3
0 5
1 7
2 9
Output:
5.00
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