Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.

def _factln(num):
    # type: (int) -> float
    """
    Computes logfactorial regularly for tractable numbers, uses Ramanujans approximation otherwise.
    """

    if num < 20:
        log_factorial = log(factorial(num))
    else:
        log_factorial = num * log(num) - num + log(num * (1 + 4 * num * (
            1 + 2 * num))) / 6.0 + log(pi) / 2

    return log_factorial