All problems

Predicting Beyond the Data

mediumPythonRegression

Copperleaf Coffee again, with the same branch reports: staff on the counter against orders served per hour, one row per shift.

An investor has asked what a café would serve during the rush at a staffing level well beyond anything it has ever tried. The manager wants the number the fitted line gives, quoted to the nearest hundredth so that the figure in the deck comes out the same on whichever machine rebuilds it — and so that a second, more awkward conversation about whether the number should be quoted at all can happen separately. The question is put to each branch in turn, at whatever staffing level the investor names for it.

Task: Print the value the least-squares straight line predicting the orders from the staffing takes at the staffing level asked about, rounded to 2 decimals.

Input

Four lines. The first holds one integer n, the number of shifts (at least 2). The second holds the n staffing counts, separated by spaces. The third holds the n orders-per-hour figures, in the same shift order. The fourth holds the staffing level to predict at. Values are decimal numbers, and the staffing counts are not all the same.

Output

One line holding the predicted orders per hour, rounded to 2 decimals and printed the way Python prints a float — 21.0, never 21.00.

Example:

Input:
5
1 2 3 4 5
3 5 7 9 11
10

Output:
21.0

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…