Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-082

Lognormal Mean and Median

Problem

For a lognormal random variable whose log has mean mu and standard deviation sigma, return [mean, median]:

mean = exp(mu + sigma^2 / 2) and median = exp(mu).

The result is a two-element list.

Hint

The median is exp(mu); the mean picks up the half-variance term.

Test cases

case 1
in: [0,1]
expected: [1.6487212707001282,1]
case 2
in: [0,0]
expected: [1,1]
case 3
in: [1,0.5]
expected: [3.080216848918031,2.718281828459045]
case 4
in: [2,1]
expected: [12.182493960703473,7.38905609893065]
Starter codePython
import math


def lognormal_mean_median(mu, sigma):
    # Your code here
    pass

4 test cases · run your code against them in the editor