from math import log, e


def loguniform(quantile: float, min_val: float, max_val: float) -> float:
    """Rescale uniform random number into a value from a log-uniform dist.

    Rescale the uniformly sampled value [0,1] into a value taken of a
    log-uniform distribution with support of [min_val, max_val].

    :param quantile: the sample taken from uniform distribution [0,1]
    :param min_val: the minimum value of this log-uniform distribution
    :param max_val: the maximum value of this log-uniform distribution
    :return: the rescaled value in the specified log-uniform distribution
    """

    if quantile > 1.0:
        raise ValueError("{} is not a valid [0, 1] quantile" .format(quantile))
    elif quantile < 0.0:
        raise ValueError("{} is not a valid [0, 1] quantile" .format(quantile))
    elif min_val >= max_val:
        raise ValueError("min value is greater than or the same as the max")
    elif min_val < 0 or max_val < 0:
        raise ValueError("the support of log-unif has to be positive")
    else:
        logunif = quantile * (log(max_val) - log(min_val)) + log(min_val)
        logunif = e**logunif

    return logunif