def ad_unif_fix(samples, pinf):
    """
    Corrects the limiting distribution for a finite sample size.
    """
    n = samples
    c = .01265 + .1757 / n
    if pinf < c:
        return (((.0037 / n + .00078) / n + .00006) / n) * g1(pinf / c)
    elif pinf < .8:
        return ((.01365 / n + .04213) / n) * g2((pinf - c) / (.8 - c))
    else:
        return g3(pinf) / n