Line Fitting Under Uncertainty
Time limit2sMemory limit256 MB
Find the line that minimizes the worst expected absolute deviation from uncertain sample values and print that error.
- Level
Hard8 of 10
- Topics
- Binary search, Geometry, Math
- Solved
- No attempts yet
Problem
Fitting a function to a finite set of points sampled from an unknown function is a basic problem in mathematics. The most common form is to find a linear function that fits the sampled points best. Suppose is sampled at . One way to measure how well fits the sample points is the error
The function values at the sample points are not known exactly. Instead you have a discrete probability distribution for each : a list of possible values with probabilities such that . The error is then defined with expected values.
Write a program that finds the linear function minimizing this error and reports the minimum error.
Input
The input holds several test cases. The first line of each test case contains , the number of sample points (). The next lines describe the sample points in increasing order of , one line per point. The line for the -th sample point starts with the position at which the function is sampled and the size of its distribution (, ). Then come the possible function values at , (), followed by the probabilities (). The real probability is divided by 100, and for each sample point the probability numbers add up to 100. All values are integers and . The last line of the input contains a single 0, which is not a test case.
Output
For each test case, print one line with the minimum error, rounded to exactly one digit after the decimal point. Round a value exactly halfway up, so 0.25 prints as 0.3.