Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexpghayes/distributions3
Probability Distributions as S3 Objects
https://github.com/alexpghayes/distributions3
Last synced: about 1 month ago
JSON representation
Probability Distributions as S3 Objects
- Host: GitHub
- URL: https://github.com/alexpghayes/distributions3
- Owner: alexpghayes
- License: other
- Created: 2019-05-08T01:38:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T06:25:50.000Z (about 2 months ago)
- Last Synced: 2024-09-17T16:51:29.315Z (about 2 months ago)
- Language: R
- Homepage: https://alexpghayes.github.io/distributions3/
- Size: 15.4 MB
- Stars: 100
- Watchers: 7
- Forks: 16
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
message = FALSE,
warning = FALSE
)
```# distributions3
[![CRAN status](https://www.r-pkg.org/badges/version/distributions3)](https://cran.r-project.org/package=distributions3)
[![Codecov test coverage](https://codecov.io/gh/alexpghayes/distributions3/branch/main/graph/badge.svg)](https://app.codecov.io/gh/alexpghayes/distributions3?branch=main)
[![R-CMD-check](https://github.com/alexpghayes/distributions3/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/alexpghayes/distributions3/actions/workflows/R-CMD-check.yaml)`distributions3`, inspired by the [eponynmous Julia package](https://github.com/JuliaStats/Distributions.jl), provides a generic function interface to probability distributions. `distributions3` has two goals:
1. Replace the `rnorm()`, `pnorm()`, etc, family of functions with S3 methods for distribution objects
2. Be extremely well documented and friendly for students in intro stat classes.
The main generics are:
- `random()`: Draw samples from a distribution.
- `pdf()`: Evaluate the probability density (or mass) at a point.
- `cdf()`: Evaluate the cumulative probability up to a point.
- `quantile()`: Determine the quantile for a given probability. Inverse of `cdf()`.## Installation
You can install `distributions3` with:
``` r
install.packages("distributions3")
```You can install the development version with:
``` r
install.packages("devtools")
devtools::install_github("alexpghayes/distributions3")
```## Basic Usage
The basic usage of `distributions3` looks like:
```{r}
library("distributions3")X <- Bernoulli(0.1)
random(X, 10)
pdf(X, 1)cdf(X, 0)
quantile(X, 0.5)
```Note that `quantile()` **always** returns lower tail probabilities. If you aren't sure what this means, please read the last several paragraphs of `vignette("one-sample-z-confidence-interval")` and have a gander at the plot.
## Contributing
If you are interested in contributing to `distributions3`, please reach out on Github! We are happy to review PRs contributing bug fixes.
Please note that `distributions3` is released with a
[Contributor Code of Conduct](https://alexpghayes.github.io/distributions3/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.## Related work
For a comprehensive overview of the many packages providing various distribution related functionality see the [CRAN Task View](https://cran.r-project.org/view=Distributions).
- [`distributional`](https://cran.r-project.org/package=distributional) provides distribution objects as vectorized S3 objects
- [`distr6`](https://cran.r-project.org/package=distr6) builds on `distr`, but uses R6 objects
- [`distr`](https://cran.r-project.org/package=distr) is quite similar to `distributions`, but uses S4 objects and is less focused on documentation.
- [`fitdistrplus`](https://cran.r-project.org/package=fitdistrplus) provides extensive functionality for fitting various distributions but does not treat distributions themselves as objects