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

Adding stable distributions #1703

Closed
wants to merge 14 commits into from
Closed

Adding stable distributions #1703

wants to merge 14 commits into from

Conversation

jaksle
Copy link

@jaksle jaksle commented Mar 30, 2023

Please be patient, I have zero experience with open source projects.

As for the code:

  • Type-1 parametrization is used, the same as explained in Wikipedia and used in SciPy, however Matlab uses type-0 parametrization. Type-1 one is usually the most convenient one for human use.
  • Pdf and cdf are calculated using integral representations. The integrated functions converge to 0 like exp(-inf) and inf*exp(-inf) which returns NaNs, they are truncated by hand in line 83 and 127. Seems to be good enough.
  • The code uses Interpolations.jl for 2D linear interpolation. If adding such dependence is a problem I may replace it.
  • Fitting is two step. First quantile method is used which returns initial estimate used in the better ecdf method. According to John P. Nolan MLE is best, but ecdf method is only slightly worse and is much, much quicker. This method fits ecdf to the theoretical one, but internally in type-0 parametrization. This is because type-1 is discontinuous at alpha = 1 which causes numerical instability, essentially location parameter becomes meaningless. Only at the end the result it is converted to type-1.
  • If I understand correctly @quantile_newton Stable should provide default implementation of cdf inversion, but it does not seem to work when I'm checking on my local version...

@jaksle
Copy link
Author

jaksle commented Jul 12, 2023

Bump. Is there an interest in this? Stable distributions seem an important class for me (depends on the background I guess) and they are provided e.g., in SciPy and Matlab.

@simsurace
Copy link
Contributor

That's nice! I'd definitely find this useful.
I think it would need some unit tests though.

@jaksle
Copy link
Author

jaksle commented Dec 2, 2023

@simsurace I've added tests. I hope there will be someone with will/time to supervise merging it. At least, the "competition" in other languages have this feature.

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2023

Codecov Report

Attention: 76 lines in your changes are missing coverage. Please review.

Comparison is base (ec68da3) 85.82% compared to head (21f1790) 85.31%.
Report is 43 commits behind head on master.

Files Patch % Lines
src/univariate/continuous/stable.jl 50.64% 76 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1703      +/-   ##
==========================================
- Coverage   85.82%   85.31%   -0.51%     
==========================================
  Files         137      145       +8     
  Lines        8315     8806     +491     
==========================================
+ Hits         7136     7513     +377     
- Misses       1179     1293     +114     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@simsurace
Copy link
Contributor

To me everything looks very clean, thanks a lot for the work. However, I don't have merge rights.

@simsurace
Copy link
Contributor

@devmotion are you able to review this, or do you know someone who is able to?

@jaksle
Copy link
Author

jaksle commented Jan 14, 2024

@devmotion Could I ask for an update on this? Currently I don't know even if this commit fits and may potentially be merged. If there'd be no reasonable horizon on making this public I'd probably change it to a separate package. Sub-optimal I my view, but better than nothing.

@jaksle
Copy link
Author

jaksle commented Mar 17, 2024

Update: this functionality is currently available using StableDistributions.jl package.

@devmotion
Copy link
Member

I just came across this PR in my backlog, sorry 🙂 I'm not strictly against adding new dependencies to Distributions but my general feeling is that the size of Distributions slows down development (and generally I tend to prefer smaller packages as a user since it allows to reduce compilation and load times), so I think it's fine to define distributions outside of Distributions.jl. For users, I think it could be helpful to list such more "official" downstream packages in the docs. The advantage of Distributions, of course, is that potentially - but not always as you can see... - more people are able to check your code and to contribute. Possibly this could be improved by moving some of such downstream packages to JuliaStats - but just moving it there without actually increasing the number of collaborators isn't very helpful either.

@jaksle jaksle closed this May 20, 2024
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

Successfully merging this pull request may close these issues.

4 participants