Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspected error in lognormal sampling #25

Open
thomasgibon opened this issue Oct 11, 2022 · 0 comments
Open

Suspected error in lognormal sampling #25

thomasgibon opened this issue Oct 11, 2022 · 0 comments

Comments

@thomasgibon
Copy link

thomasgibon commented Oct 11, 2022

Hi, we have been struggling with @alvarojhahn about how the lognormal distribution is defined.

The lognormal sampling for a given parameter is done at the following line of code:

self._distrib = lognorm(self.default, self.std)

However, the scipy documentation indicates that a lognormal distribution can be configured with lognorm, using scale and shape s, with scale = exp(mu) and s = sigma with mu and sigma being the mean and standard deviation of the corresponding normal distribution. This means that mu = param.default and sigma = param.std for a lognormal-distributed parameter.

BUT apparently scale takes the median (exp(mu)) and not the mean, so you should not pass np.exp(param.default) but rather the following:

self._distrib = lognorm(scale=self.default * np.exp(-self.std**2/2), s=self.std)

It is confusing, because using the log-transformed mean and the non-transformed standard deviation is inconsistent, but it seems to yield the right results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant