All problems

Which Machine Made the Defective Item?

mediumPythonBayes' Theorem

Kestrel Manufacturing builds bicycle hubs on two lines. One machine is usually the workhorse and turns out most of what leaves the floor; the other covers the rest. The two are never equally reliable, and the sloppier one is not always the busier one.

A customer has returned a defective hub. The ink stamp that would say which line built it has worn away, and the maintenance supervisor can only strip down one machine before the end of the shift - so she wants a probability, not an opinion. The production split and the two defect rates are re-measured every quarter, so the figure is worked out from that quarter's numbers.

Every hub comes off one of these two machines.

Task: Print the probability that the returned hub came from Machine 2, as a single number rounded to 4 decimals. Round once, at the end.

Input

Four lines, each a decimal between 0 and 1: Machine 1's share of total production, the fraction of Machine 1's own output that is defective, then the same two figures for Machine 2. The two production shares add to 1.

Output

One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.625, never 0.6250.

Example:

Input:
0.6
0.02
0.4
0.05

Output:
0.625

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…