Premium problem75. Spam Filter on One Word

Easy Locked

A fraction p_spam of mail is spam. A particular word appears in spam with probability p_word_given_spam and in legitimate mail with p_word_given_ham. The word appears in a message. Return the probability the message is spam.

Input

p_spam = 0.3
p_word_given_spam = 0.6
p_word_given_ham = 0.02

Output

0.9278350515463917

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)