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

[FR] Truncated Power Law distribution #1806

Closed
Qazalbash opened this issue May 26, 2024 · 0 comments · Fixed by #1807
Closed

[FR] Truncated Power Law distribution #1806

Qazalbash opened this issue May 26, 2024 · 0 comments · Fixed by #1807
Labels
enhancement New feature or request

Comments

@Qazalbash
Copy link
Contributor

Description

I miss truncated power law distribution in NumPyro alot. I have implemented them on side for my own use. I was thinking if we could add them to NumPyro, it would be great.

@fehiepsi fehiepsi added the enhancement New feature or request label May 28, 2024
fehiepsi pushed a commit that referenced this issue Sep 17, 2024
…ated Power Law (#1807)

* implementation of DoublyTruncatedPowerLaw

* implementation of LowerTruncatedPowerLaw

* chore: mathematical description in docstrings

* chore: mathematical details of `LowerTruncatedPowerLaw`

* chore: Fix bug in DoublyTruncatedPowerLaw cdf and icdf calculation

* chore: Refactor mean and variance calculation by using kth-moment in DoublyTruncatedPowerLaw

* chore: Refactor mean and variance calculation in LowerTruncatedPowerLaw

* chore: masking in icdf of LowerTruncatedPowerLaw

* chore: entropy of LowerTruncatedPowerLaw

* chore: `lax.sqaure` replaced with `jnp.sqaure`

* chore: moments and entropy were extra and removed

* chore: unit tests

* fix: nan gradients fixed, values still diverging

* Updated UpperTruncatedPowerLaw with adequate derivations, including fixing the discontinuity point for alpha equals minus one and correct tangents for lower and upper bounds.

* Changed constrains of alpha of LowerTruncatedPowerLaw to the smaller minus one and also changed equation to keep equational uniformity UpperTruncatedPowerLaw to and improved stability of the calculation by integrating formula parts inside log to prevent NaN values due to negative values of some parts that could balance out in the end.

* chore: code and docstring formated

* chore: equation refactor and simplified

* chore: equation refactor and simplified

* chore: use numpy arrays and numpy constants

* chore: high precision computation enable for powerlaws

* chore: `__name__` attribute calls removed

* chore: powerlaws shifted with truncated distributions

* chore: spelling mistakes fixed with code spell checker pre-commit hook

* fix typo: perforance->perforamce->performance

* chore: explicit enabling/disabling of 64bit floating point numbers

* chore: disable everytime and enable x64 for power laws

* chore: disable x64 for every test

* chore: linked explanation in comments for disabling x64 for future reference for devs

* chore: high precision test handeled efficiently for DoublyTruncatedPowerLaw

* chore: high precision exception handled in test_log_prob_gradient

---------

Co-authored-by: David Ziegler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants