import mpmath


def cdf(x, a, b):
    """
    Cumulative distribution function of the beta distribution.
    """
    if a <= 0 or b <= 0:
        raise ValueError('The shape parameters a and b must be greater '
                         'than 0.')
    if x < 0:
        return mpmath.mp.zero
    if x > 1:
        return mpmath.mp.one
    return mpmath.betainc(a, b, x1=0, x2=x, regularized=True)