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

Add nu parametrization to beta distribution #6344

Merged
merged 10 commits into from
Feb 3, 2023

Conversation

alekracicot
Copy link
Contributor

@alekracicot alekracicot commented Nov 28, 2022

What is this PR about?
...
This PR addresses closes #5023 and closes #6295 and incorporates the mu, nu parametrization to the Beta distribution as described here https://en.wikipedia.org/wiki/Beta_distribution as well as fixing the error on the sigma bounds in the docstring.

As for the test, I implemented one, on the logp, and it passed. I assumed that if logp was the same across parametrization, cdf and others would follow. Let me know if this is sufficient.

Checklist

Major / Breaking Changes

  • ...

Bugfixes / New features

  • The Beta distribution can now be parametrized by nu.

Docs / Maintenance

  • ...

@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Merging #6344 (8402adf) into main (4cac135) will decrease coverage by 8.69%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6344      +/-   ##
==========================================
- Coverage   94.72%   86.04%   -8.69%     
==========================================
  Files         148      148              
  Lines       27487    27818     +331     
==========================================
- Hits        26038    23936    -2102     
- Misses       1449     3882    +2433     
Impacted Files Coverage Δ
pymc/distributions/continuous.py 97.68% <100.00%> (+<0.01%) ⬆️
pymc/tests/distributions/test_continuous.py 99.77% <100.00%> (+<0.01%) ⬆️
pymc/tests/logprob/test_utils.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_cumsum.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_mixture.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_abstract.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_rewriting.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_joint_logprob.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/logprob/test_composite_logprob.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_truncated.py 0.00% <0.00%> (-99.49%) ⬇️
... and 72 more

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening the PR. I left a couple of suggestion below.

pymc/distributions/continuous.py Show resolved Hide resolved
pymc/tests/distributions/test_continuous.py Outdated Show resolved Hide resolved
Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just not sure about the "sample size" part in the docstrings.

@@ -1059,10 +1059,11 @@ class Beta(UnitContinuous):
Support :math:`x \in (0, 1)`
Mean :math:`\dfrac{\alpha}{\alpha + \beta}`
Variance :math:`\dfrac{\alpha \beta}{(\alpha+\beta)^2(\alpha+\beta+1)}`
Sample size :math:`\alpha + \beta`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this one. It's not really a property of the distribution, but an interpretation of the parameters, assuming a specific model

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add this as a comment in the docstring, but I agree that this is not a property per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitating as well, I will remove the reference to "sample size" without the full explanation. Should I add:

'nu : tensor_like of float, optional
Alternative "sample size" of a Beta distribution for the Haldane prior probability Beta(0,0) (nu > 0) .

in the parameter section?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the parameter description is good enough as it is now.

We can perhaps add a link to the relevant Wikipedia section instead of mentioning the Haldane prior?

https://en.m.wikipedia.org/wiki/Beta_distribution#Mean_and_sample_size

@alekracicot alekracicot marked this pull request as ready for review December 2, 2022 14:24
@ricardoV94
Copy link
Member

Pre-commit is failing, otherwise the PR looks good to me

@michaelosthege michaelosthege merged commit ac9652e into pymc-devs:main Feb 3, 2023
Dhruvanshu-Joshi pushed a commit to Dhruvanshu-Joshi/pymc that referenced this pull request Feb 7, 2023
* Add (mu, nu) parametrization

* add test beta logp

* Add relationship between alpha, beta and nu

* change test structure

* remove white space accidently added in docstring

* remove sample size from docstring

---------

Co-authored-by: Michael Osthege <michael.osthege@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: wrong bound for sigma in docstring of Beta Invalid values being used for testing Beta distribution
4 participants