import math


def lmoments_parameter_estimation_generalized_logistic(lambda1, lambda2, tau):
    """Return the location, scale and shape or the generalized logistic distribution

    Based on SUBROUTINE PELGLO of the LMOMENTS Fortran package version 3.04, July 2005

    :param lambda1: L-moment-1
    :param lambda2: L-moment-2
    :param tau:  L-moment-3 /  L-moment-2
    :return: (*float*) location, scale and shape
    """
    assert lambda2 > 0 and -1 < -tau < 1
    try:
        k = -tau
        a = math.sin(k * math.pi) / (k * math.pi)
        s = lambda2 * a
        m = lambda1 - (s / k) * (1.0 - 1.0 / a)
        return m, s, k
    except ZeroDivisionError:
        return lambda1, lambda2, 0.0