All problems

Laplace-Smoothed Likelihood

easyPythonNaive Bayes

Halyard Mail's filter now looks at one word at a time and asks how likely that word is under a given label -- its likelihood. Raw sighting counts will not do. A word the archive never recorded under this label would come out at exactly nothing, and one nothing is enough to knock the label out however well the rest of the message fits. So Halyard credits every word in the vocabulary with one extra sighting under the label, and grows the label's total sighting count by one for each distinct vocabulary word so the books still balance.

Task: Print the likelihood of this word under this label, with Halyard's credit applied.

Input

One line holding three integers separated by single spaces: how many times the word was recorded under this label, the total sightings recorded under this label, and the number of distinct words in the vocabulary.

Output

One line holding the likelihood rounded to 4 decimal places. A word with no recorded sightings still comes out above zero.

Example:

Input:
5 100 50

Output:
0.0400

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…