LogLinkSpec.mean_correction#

LogLinkSpec.mean_correction(posterior, output_var='y')[source]#

Return exp(sigma**2 / 2), the LogNormal mean/median ratio.

For y \sim \text{LogNormal}(\mu, \sigma) the conditional median is exp(mu) while the conditional mean is exp(mu + sigma**2 / 2). The ratio exp(sigma**2 / 2) therefore rescales a median-based quantity to the mean.

Raises:
ValueError

If the likelihood scale f"{output_var}_sigma" is not present in the posterior (e.g. a fixed-sigma likelihood), so the mean correction cannot be computed.