All problems

The Unnormalized Posterior

mediumPythonNaive Bayes

Halyard Mail now has, for one label, its prior -- how common the label is in the archive -- and one likelihood per feature of the message being filtered, each the chance of seeing that feature under this label. These have to become a single score for the label. Halyard's filter treats the features as carrying evidence entirely of their own: knowing one of them tells you nothing about the others once the label is fixed. So the chance of the whole set turning up together under this label is exactly what the separate chances imply when nothing links them, and the label's score is that chance with the prior folded in.

Task: Print this label's score.

Input

The first line holds the label's prior. The second line holds one integer n, the number of features. The third line holds n likelihoods separated by single spaces.

Output

One line holding the score rounded to 6 decimal places. The score is not rescaled against any other label -- print it as it stands. Round once, at printing time.

Example:

Input:
0.4
2
0.5 0.2

Output:
0.040000

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…