Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Add `BernoulliLogit`

Open devmotion opened this issue 3 years ago • 4 comments

This PR adds a Bernoulli distribution with the logit of the success rate as parameter.

This is motivated by use cases e.g. in Turing (https://github.com/TuringLang/Turing.jl/issues/1890) where it is more convenient to work with unconstrained parameters. First class support for the parameterization allows us to evaluate e.g. the log pdf more efficiently.

devmotion avatar Oct 05 '22 14:10 devmotion

Can you mention “parametrized by the log of the odds Logitp = p/(1-p)” in the docstring

mschauer avatar Oct 05 '22 15:10 mschauer

Codecov Report

Base: 85.94% // Head: 85.50% // Decreases project coverage by -0.44% :warning:

Coverage data is based on head (9ed9c73) compared to base (4c27f7d). Patch coverage: 12.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1623      +/-   ##
==========================================
- Coverage   85.94%   85.50%   -0.45%     
==========================================
  Files         129      130       +1     
  Lines        8098     8155      +57     
==========================================
+ Hits         6960     6973      +13     
- Misses       1138     1182      +44     
Impacted Files Coverage Δ
src/Distributions.jl 100.00% <ø> (ø)
src/univariates.jl 74.07% <ø> (ø)
src/univariate/discrete/bernoullilogit.jl 12.00% <12.00%> (ø)
src/univariate/continuous/skewnormal.jl 65.62% <0.00%> (ø)
src/eachvariate.jl 90.47% <0.00%> (+4.76%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Oct 09 '22 23:10 codecov-commenter

Can you mention “parametrized by the log of the odds Logitp = p/(1-p)” in the docstring

Are you interested in the term "log-odds" specifically? The docstring already mentions that it is parameterized by the logit of the success rate, and log-odds is just another name for the logit (see e.g. https://en.wikipedia.org/wiki/Logit).

devmotion avatar Oct 10 '22 08:10 devmotion

Generally this PR should be ready and well-tested.

devmotion avatar Oct 10 '22 08:10 devmotion

should be good to merge when tests pass I think

matbesancon avatar Oct 16 '22 13:10 matbesancon

The docstring already mentions that it is parameterized by the logit of the success rate

Well, that requires you knowing what a logit is. Saying it is "parametrised by logitp = log(p/(1-p)) where p is the success rate" makes everything immediately clear to the passerby - doesn't it?

mschauer avatar Oct 16 '22 13:10 mschauer

Ah I see, I thought the main point of your comment was the term log odds. I changed the docstring, hopefully it is clearer now.

devmotion avatar Oct 16 '22 14:10 devmotion