All problems

Confidence Band Width and Sample Size

hardPythonSeabornci

The shaded band the rig chart draws around its fitted line gets narrower as more readings are taken, which is why Calder Engineering runs long tests before quoting anything. The sign-off sheet carries a plain number standing in for that band's width, so two test runs can be compared without holding their charts side by side.

Task: Print the standard error of the fit, as defined below.

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 and take each reading's recorded y minus the line's value at that x. Print the sample standard deviation of those leftovers -- the version treating them as a sample of a larger population rather than the whole of it -- scaled down by the square root of the number of readings.

Example:

Input:
4
1 2
2 4
3 5
4 9

Output:
0.39

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…