import math


def compute_logarithmic_mean_stddev(m, stddev):
    """ compute mean of log x with mean and std. of x
    Args:
        m: arithmetic mean of x
        stddev: arithmetic standard deviation of x

        mu = 2*log(m) - 0.5*log(v + m**2)
        std = sqrt(log(V/m**2 +1))

        if m is zero, then return -999, 0.0

    Returns: mean and std of log x

    """
    assert m >= 0.0
    assert stddev >= 0.0

    if m:
        mu = 2.0 * math.log(m) - 0.5 * math.log(stddev**2.0 + m**2.0)
        std = math.sqrt(math.log(stddev**2.0 / m**2.0 + 1))
    else:
        mu = -999
        std = 0.0

    return mu, std