{"id":14068410,"url":"https://github.com/mitchelloharawild/distributional","last_synced_at":"2025-10-20T09:23:05.002Z","repository":{"id":45166350,"uuid":"211980774","full_name":"mitchelloharawild/distributional","owner":"mitchelloharawild","description":"Vectorised distributions for R","archived":false,"fork":false,"pushed_at":"2025-03-27T07:58:00.000Z","size":3602,"stargazers_count":100,"open_issues_count":33,"forks_count":17,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T12:08:51.563Z","etag":null,"topics":["probability-distribution","r","statistics","vctrs"],"latest_commit_sha":null,"homepage":"https://pkg.mitchelloharawild.com/distributional","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchelloharawild.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-01T00:07:06.000Z","updated_at":"2025-03-27T07:53:08.000Z","dependencies_parsed_at":"2023-01-22T06:46:18.295Z","dependency_job_id":"9bd6798d-4801-4624-bce9-a78282cb84d9","html_url":"https://github.com/mitchelloharawild/distributional","commit_stats":{"total_commits":463,"total_committers":8,"mean_commits":57.875,"dds":0.5075593952483801,"last_synced_commit":"46a66225b9420c8c2bafd64b234949a67af67ed9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchelloharawild%2Fdistributional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchelloharawild%2Fdistributional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchelloharawild%2Fdistributional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchelloharawild%2Fdistributional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchelloharawild","download_url":"https://codeload.github.com/mitchelloharawild/distributional/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856544,"owners_count":21007621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["probability-distribution","r","statistics","vctrs"],"created_at":"2024-08-13T07:06:09.522Z","updated_at":"2025-10-20T09:22:59.952Z","avatar_url":"https://github.com/mitchelloharawild.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nset.seed(0)\n```\n\n# distributional\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![R-CMD-check](https://github.com/mitchelloharawild/distributional/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mitchelloharawild/distributional/actions/workflows/R-CMD-check.yaml)\n\u003c!-- [![Coverage Status](https://codecov.io/gh/mitchelloharawild/distributional/branch/master/graph/badge.svg)](https://codecov.io/github/mitchelloharawild/distributional?branch=master) --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/distributional)](https://CRAN.R-project.org/package=distributional)\n![Download count](https://cranlogs.r-pkg.org/badges/last-month/distributional)\n\u003c!-- badges: end --\u003e\n\nThe distributional package allows distributions to be used in a vectorised context. It provides methods which are minimal wrappers to the standard d, p, q, and r distribution functions which are applied to each distribution in the vector. Additional distributional statistics can be computed, including the `mean()`, `median()`, `variance()`, and intervals with `hilo()`. \n\nThe distributional nature of a model's predictions is often understated, with default output of prediction methods usually only producing point predictions. Some R packages (such as [forecast](https://CRAN.R-project.org/package=forecast)) further emphasise uncertainty by producing point forecasts and intervals by default, however the user's ability to interact with them is limited. This package vectorises distributions and provides methods for working with them, making distributions compatible with prediction outputs of modelling functions. These vectorised distributions can be illustrated with [ggplot2](https://CRAN.R-project.org/package=ggplot2) using the [ggdist](https://CRAN.R-project.org/package=ggdist) package, providing further opportunity to visualise the uncertainty of predictions and teach distributional theory.\n\n## Installation\n\nYou can install the released version of distributional from [CRAN](https://CRAN.R-project.org/package=distributional) with:\n\n```{r, eval = FALSE}\ninstall.packages(\"distributional\")\n```\n\nThe development version can be installed from [GitHub](https://github.com/mitchelloharawild/distributional) with:\n\n```{r, eval = FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"mitchelloharawild/distributional\")\n```\n\n## Examples\n\nDistributions are created using `dist_*()` functions. A list of included distribution shapes can be found here: \u003chttps://pkg.mitchelloharawild.com/distributional/reference/\u003e\n\n```{r object}\nlibrary(distributional)\nmy_dist \u003c- c(dist_normal(mu = 0, sigma = 1), dist_student_t(df = 10))\nmy_dist\n```\n\nThe standard four distribution functions in R are usable via these generics:\n\n```{r}\ndensity(my_dist, 0) # c(dnorm(0, mean = 0, sd = 1), dt(0, df = 10))\ncdf(my_dist, 5) # c(pnorm(5, mean = 0, sd = 1), pt(5, df = 10))\nquantile(my_dist, 0.1) # c(qnorm(0.1, mean = 0, sd = 1), qt(0.1, df = 10))\ngenerate(my_dist, 10) # list(rnorm(10, mean = 0, sd = 1), rt(10, df = 10))\n```\n\nYou can also compute intervals using `hilo()`\n\n```{r hilo}\nhilo(my_dist, 0.95)\n```\n\nAdditionally, some distributions may support other methods such as mathematical operations and summary measures. If the methods aren't supported, a transformed distribution will be created.\n\n```{r math}\nmy_dist\nmy_dist*3 + 2\nmean(my_dist)\nvariance(my_dist)\n```\n\nYou can also visualise the distribution(s) using the [ggdist](https://mjskay.github.io/ggdist/) package.\n\n```{r plot}\nlibrary(ggdist)\nlibrary(ggplot2)\n\ndf \u003c- data.frame(\n  name = c(\"Gamma(2,1)\", \"Normal(5,1)\", \"Mixture\"),\n  dist = c(dist_gamma(2,1), dist_normal(5,1),\n           dist_mixture(dist_gamma(2,1), dist_normal(5, 1), weights = c(0.4, 0.6)))\n)\n\nggplot(df, aes(y = factor(name, levels = rev(name)))) +\n  stat_dist_halfeye(aes(dist = dist)) + \n  labs(title = \"Density function for a mixture of distributions\", y = NULL, x = NULL)\n```\n\n## Related work\n\nThere are several packages which unify interfaces for distributions in R:\n\n* stats provides functions to work with possibly multiple distributions (comparisons made below).\n* [distributions3](https://cran.r-project.org/package=distributions3) represents singular distributions using S3, with particularly nice documentation. This package makes use of some code and documentation from this package.\n* [distr](https://cran.r-project.org/package=distr) represents singular distributions using S4.\n* [distr6](https://cran.r-project.org/package=distr6) represents singular distributions using R6.\n* Many more in the [CRAN task view](https://cran.r-project.org/view=Distributions)\n\nThis package differs from the above libraries by storing the distributions in a vectorised format. It does this using [vctrs](https://vctrs.r-lib.org/), so it should play nicely with the tidyverse (try putting distributions into a tibble!).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchelloharawild%2Fdistributional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchelloharawild%2Fdistributional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchelloharawild%2Fdistributional/lists"}