All problems

Predicting a Probability

easyPythonLogistic Regression

The late-delivery model is fitted, and now the dispatch screen has to run it. A job is described by several numbers — distance, parcels, how far behind the driver already is — and the model holds one weight per number plus a starting amount that applies before any of them are read. Those combine into the unbounded score, and the screen shows the probability that score corresponds to, using the same standard sigmoid curve on the natural exponential as before.

Task: Print the probability the model gives this job.

Input

The first line holds one integer k, how many numbers describe a job, where 1 <= k <= 50. The second line holds k + 1 numbers separated by single spaces: the starting amount first, then the k weights. The third line holds the job's k numbers separated by single spaces, in the same order as the weights.

Output

One line holding the probability rounded to 4 decimal places, with no label.

Example:

Input:
2
0 1 1
1 1

Output:
0.8808

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…