import mpmath


def invsf(p, loc=0, scale=1):
    """
    Inverse survival function of the logistic distribution.
    """
    with mpmath.extradps(5):
        p = mpmath.mpf(p)
        loc = mpmath.mpf(loc)
        scale = mpmath.mpf(scale)
        x = loc + scale*(mpmath.log1p(-p) - mpmath.log(p))
    return x