Solution (source code)

= Solution

By <Bayes' theorem>, provided $p+q>0$,
$$
\boxed{P(M\mid S)=\frac{P(S\mid M)P(M)}{P(S)}=\frac{p}{p+q}}.
$$
If $p=q=0$, singing has <probability> zero and the stated observation cannot occur in this model; that <conditional probability> is undefined.