Downweighting Outliers With robust=True
One Calder Engineering test run contains a reading from a rig that was already failing, and a least-squares line is helpless against it: every miss is squared, so one absurd reading dominates the fit. The chart is therefore drawn with a method that discounts readings it cannot reconcile. The sheet carries a crude companion figure, built from middles rather than averages, that no single reading can shift.
Task: Print the middle y value shared over the middle x value.
Input
The first line holds one integer n, where 1 <= n <= 1000. Then come n lines, each holding a reading's x and y separated by a single space, x first. The middle x value is never zero.
Output
One line, rounded to 2 decimal places. Take each column's middle value separately: sort that column on its own and take the central entry, or the average of the two central entries when the count is even. The answer is the y middle over the x middle -- the ratio of the two middles, not the middle of the per-reading ratios.
Example:
Input:
5
1 2
2 4
3 6
4 8
5 100
Output:
2.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