def bayesian(p_h, p_o_h, p_o_not_h):
    """Calculate the probability of hypothesis `h` given the new observation
       `o`, where ::

       - `p_h` is the probability before the new observation was made,

       - `p_o_h` is the probability of the observation when the
         hypothesis `h` is true,

       - `p_o_not_h` is the probability of the observation when the
         hypothesis `h` is false.

       Consider a disease that appears in 1% of the population and a test for
       that disease is positive 80% (or 85%, or 90%) of the time when the
       disease is present and 10% (or 5%, or 1%) of the time when the disease
       is not present:

       >>> print ("%5.3f" % bayesian (0.01, 0.80, 0.10))
       0.075
       >>> print ("%5.3f" % bayesian (0.01, 0.85, 0.05))
       0.147
       >>> print ("%5.3f" % bayesian (0.01, 0.90, 0.01))
       0.476
       >>> print ("%5.3f" % bayesian (0.01, 0.99, 0.01))
       0.500

       Because so many people don't have the disease, the false positives far
       exceed the small percentage of those tested who actually have the
       disease.

       >>> print ("%5.3f" % bayesian (0.50, 0.80, 0.10))
       0.889
       >>> print ("%5.3f" % bayesian (0.50, 0.85, 0.05))
       0.944
       >>> print ("%5.3f" % bayesian (0.50, 0.90, 0.01))
       0.989
       >>> print ("%5.3f" % bayesian (0.50, 0.99, 0.01))
       0.990
    """
    p_not_h = 1.0 - p_h
    p_h_times_p_o_h = p_h * p_o_h
    return p_h_times_p_o_h / (p_h_times_p_o_h + p_not_h * p_o_not_h)
