Estimating the log-space sigma (std) parameter of a lognormal distribution from its regular-space mean and variance validaters,
I've spent a lot of time on this issue and I can't figure it out yet.
So, a lognormal distribution is being defined as follow: X=e^(μ + σ Z), where Z is a standard normal variable.
Now, I want to estimate σ from the standard deviation of the resulting random variable X. Notice how the sigma is the sigma of the Z in the log space instead of the veritable standard deviation of the resulting X (that means: the sqrt of the second moment of X).
I've tried to start from the equation of the second moment here and here and here to estimate the variance of X from its σ, however I couldn't get wolfram alpha to invert the equation (or maybe I don't understand how to use the answer) to get σ in function of the variance of X (or in function of the standard deviation of X. Wolfram always finds that σ is equal to zero or to some imaginary numbers, and there seems to have problems with these imaginary numbers and transcendental numbers.
Also, as stated on Wikipedia, the base e is not important in the expression X=e^(μ + σ Z):

This relationship is true regardless of the base of the logarithmic or exponential function. if log_a(X) is normally distributed, then so is log_b(X) for any two positive numbers a or b that are not equal to 1.

I am working with base two (2) instead of the natural exponential base (e) to reduce numerical errors in binary floating point numbers when manipulating the numbers in Python.
To sum up, I am looking for a way to find σ from the standard deviation of X. I would like to do that ideally in base two, and ideally in Python. I would like to find one simple formula that works.

EDIT: finally this answer is not good. It is close to be good, however I get a difference of close 0.85 compared to the real standard deviation of X when I measure back what it gives.
I seem to have finally found my answer with the following formula with one of the imaginary roots:
https://www.wolframalpha.com/input?i=sqrt%28log%281%2F2+e%5E%28-2+y%29+%28e%5E%282+y%29+%2B+sqrt%28e%5E%284+y%29+%2B+4+e%5E%282+y%29+x%5E2%29%29%29%29
where x is the regular std of X, and where y is the μ parameter.
In Python and in base 2, this makes:
def from_regular_mean_std(
    mean: float,
    std: float,
    hard_clip_min: float = None,
    hard_clip_max: float = None
):
    log2_space_mean = math.log2(mean)

    y = log2_space_mean
    x = std
    log2_space_std = math.sqrt(math.log2(
        0.5 * 2**(-2 * y) * (2**(2 * y) + math.sqrt(2**(4 * y) + 4 * 2**(2 * y) * x**2))
    ))

    from neuraxle.hyperparams.distributions import LogNormal
    return LogNormal(
        log2_space_mean=log2_space_mean,
        log2_space_std=log2_space_std,
        hard_clip_min=hard_clip_min,
        hard_clip_max=hard_clip_max
    )

