Repository navigation
FIX: simulate_glm(sample=True) for gamma returns exp(mu) instead of gamma samples - #401
Merged
Merged
Conversation
It returned exp(mu) deterministically. Draw shape-1 gamma samples with mean mu, matching the likelihood used for fitting.
Member
|
Thanks @rpinho . I realized that the docstring of |
Contributor
Author
|
Thanks. Agreed, the docstring doesn't say what sample changes in the return value. I can add a few lines for that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
distr='gamma'andsample=True,simulate_glmreturnsnp.exp(mu): the same value for every seed, with no noise, and the wrong mean. For example, a mean of 1.103 gives 3.014 for every observation.This PR draws
random_state.gamma(shape=1.0, scale=mu), i.e. shape-1 gamma observations with meanmu, matching the likelihood used for fitting. With 20,000 draws at that mean, the sample mean is 1.104 and the variance 1.19 (expected about 1.103 and 1.22). The same seed reproduces the same draws.sample=Falseis unchanged.Test:
test_simulate_gamma_samplesintests/test_pyglmnet.pyfails on master and passes here. The rest of the suite is unchanged (same pre-existing failures on master as noted in the Bernoulli PR).Open PR #390's
GammaSoftplus.simulatealso returnsnp.exp(mu), so the same change would apply there.