add: beta probability distribution #1139
Conversation
more appropriate and efficient than an entirely new beta special function
|
locally wrote it relying on the changes made in #1133 will leave as draft for now |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1139 +/- ##
==========================================
- Coverage 68.81% 68.68% -0.14%
==========================================
Files 408 411 +3
Lines 13726 13758 +32
Branches 1552 1552
==========================================
+ Hits 9446 9450 +4
- Misses 4280 4308 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a Beta probability distribution implementation to stats, backed by new Beta-related special functions colocated in stdlib_specialfunctions_gamma, along with tests, examples, and specification docs.
Changes:
- Introduces
stdlib_stats_distribution_betawithrvs_beta,pdf_beta, andcdf_beta(real + complex overloads). - Adds
beta,log_beta, andincomplete_betatostdlib_specialfunctions_gamma, plus corresponding unit tests. - Wires new module/tests/examples/docs into CMake and the specs index.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/stats/stdlib_stats_distribution_beta.fypp |
New Beta distribution implementation (rvs/pdf/cdf). |
src/specialfunctions/stdlib_specialfunctions_gamma.fypp |
Adds Beta-related special functions used by the distribution. |
test/stats/test_distribution_beta.fypp |
New Beta distribution test coverage. |
test/stats/CMakeLists.txt |
Registers the new Beta distribution test. |
test/specialfunctions/test_specialfunctions_gamma.fypp |
Adds tests for beta, log_beta, and incomplete_beta. |
src/stats/CMakeLists.txt |
Includes the new Beta distribution module in the stats build. |
example/stats_distribution_beta/example_beta_rvs.f90 |
Example usage for rvs_beta. |
example/stats_distribution_beta/example_beta_pdf.f90 |
Example usage for pdf_beta. |
example/stats_distribution_beta/example_beta_cdf.f90 |
Example usage for cdf_beta. |
example/stats_distribution_beta/CMakeLists.txt |
Builds the new Beta distribution examples. |
example/CMakeLists.txt |
Adds the Beta distribution examples subdirectory. |
doc/specs/stdlib_stats_distribution_beta.md |
New Beta distribution specification page. |
doc/specs/index.md |
Adds Beta distribution to the specs index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Thanks, @Calluumm. Looks good and consistent with gamma and previous distribution modules.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
numerical stability change suggested by copilot
should address the suggestions
|
This commit should address the above suggestions they can be pure elementals yes, locally passed everything |
made a and b paramters and reduced the elements
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
|
I think I've resolved everything you suggested with this commit @jalvesz @jvdp1 I made amends to the cdf example and subsequently the pdf example which had the same issues |
applied a check(all()) approach to the errors, left out an error variable to stay in line with the other distribution functions
|
Applied all suggested changes with exception to using an error variable in tests. The other distribution functions don't so this would be standard to them. If all of them move to use it it could be done in a seperate PR I think. |
Adds a beta distribution to stats
This is a modernisation/continuation of #286 all credit to the original author.
Comparatively to #286 :
Tests are standardised and modernised to current stdlib standards
Beta calculations are moved to the gamma specialfunctions module
Documentation changed to modern standards
Build tests passed fine, calculations matched that of scipy
I think beta calculations are best suited in the gamma specialfunctions rather than their own file or within the beta distribution module for code efficiency and later use
@sebastian-mutz