{"id":18712107,"url":"https://github.com/clbustos/distribution","last_synced_at":"2025-04-12T12:31:28.220Z","repository":{"id":1345152,"uuid":"1291402","full_name":"clbustos/distribution","owner":"clbustos","description":"Statistical Distributions multi library wrapper. Uses Ruby by default and C (statistics2/GSL) or Java extensions where available.","archived":false,"fork":false,"pushed_at":"2020-07-05T04:25:27.000Z","size":1181,"stargazers_count":141,"open_issues_count":13,"forks_count":52,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-07T12:52:18.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clbustos.png","metadata":{"files":{"readme":"README.md","changelog":"History.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-01-25T13:11:11.000Z","updated_at":"2023-05-28T18:31:51.000Z","dependencies_parsed_at":"2022-08-16T13:10:42.255Z","dependency_job_id":null,"html_url":"https://github.com/clbustos/distribution","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbustos%2Fdistribution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbustos%2Fdistribution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbustos%2Fdistribution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clbustos%2Fdistribution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clbustos","download_url":"https://codeload.github.com/clbustos/distribution/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566503,"owners_count":21125678,"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":[],"created_at":"2024-11-07T12:40:50.969Z","updated_at":"2025-04-12T12:31:28.213Z","avatar_url":"https://github.com/clbustos.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# [Distribution](https://github.com/sciruby/distribution)\n\n[![Build Status](https://travis-ci.org/SciRuby/distribution.svg?branch=master)](https://travis-ci.org/SciRuby/distribution)\n[![Code Climate](https://codeclimate.com/github/SciRuby/distribution/badges/gpa.svg)](https://codeclimate.com/github/SciRuby/distribution)\n\nDistribution is a gem with several probabilistic distributions. Pure Ruby is used by default, C (GSL) or Java extensions are used if available. Some facts:\n\n- Very fast ruby 1.9.3+ implementation, with improved method to calculate factorials and other common functions.\n- All methods tested on several ranges. See `spec/`.\n- Code for normal, Student's t and chi square is lifted from the [statistics2 gem](https://rubygems.org/gems/statistics2). Originally at [this site](http://blade.nagaokaut.ac.jp/~sinara/ruby/math/statistics2).\n- The code for some functions and RNGs was lifted from Julia's [Rmath-julia](https://github.com/JuliaLang/Rmath-julia), a patched version of R's standalone math library.\n\nThe following table lists the available distributions and the methods available for each one. If a field is marked with an *x*, that distribution doesn't have that method implemented.\n\n| Distribution     | PDF | CDF | Quantile | RNG | Mean | Mode | Variance | Skewness | Kurtosis | Entropy |\n| :--------------- | :-: | :-: | :------: | :-: | :--: | :--: | :------: | :------: | :------: | :-----: |\n| Uniform          | x   | x   | x        | x   | x    | x    | x        | x        | x        | x       |\n| Normal           | x   | x   | x        | x   | x    | x    | x        | x        | x        | x       |\n| Lognormal        |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Bivariate Normal |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Exponential      |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Logistic         |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| t-Student        |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Chi Square       |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Fisher-Snedecor  |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Beta             |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Gamma            |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Weibull          |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Binomial         |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Poisson          |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n| Hypergeometric   |     |     | x        | x   | x    | x    | x        | x        | x        | x       |\n\n## Installation\n\n```\n$ gem install distribution\n```\n\nYou can install GSL for better performance:\n\n* For Mac OS X: `brew install gsl`\n* For Ubuntu / Debian: `sudo apt-get install gsl`\n\nAfter successfully installing the library:\n\n```bash\n$ gem install rb-gsl\n```\n\n## Examples\n\nYou can find automatically generated documentation on [RubyDoc](http://www.rubydoc.info/github/sciruby/distribution/master).\n\n```\n# Returns Gaussian PDF for x.\npdf = Distribution::Normal.pdf(x)\n\n# Returns Gaussian CDF for x.\ncdf = Distribution::Normal.cdf(x)\n\n# Returns inverse CDF (or p-value) for x.\npv = Distribution::Normal.p_value(x)\n\n# API.\n\n# You would normally use the following\np = Distribution::T.cdf(x)\n\n# to get the cumulative probability of `x`. However, you can also:\n\ninclude Distribution::Shorthand\ntdist_cdf(x)\n```\n\n## API Structure\n\n```ruby\nDistribution::\u003cname\u003e.(cdf|pdf|p_value|rng)\n```\n\nOn discrete distributions, exact Ruby implementations of pdf, cdf and p_value could be provided, using\n\n```\n  Distribution::\u003cname\u003e.exact_(cdf|pdf|p_value)\n```\n\nmodule Distribution::Shorthand provides (you guess?) shortands method to call all methods\n\n```\n  \u003cDistribution shortname\u003e_(cdf|pdf|p|r)\n```\n\nOn discrete distributions, exact cdf, pdf and p_value are\n\n```\n  \u003cDistribution shortname\u003e_(ecdf|epdf|ep)\n```\n\nShortnames for distributions:\n\n  * Normal: norm\n  * Bivariate Normal: bnor\n  * T: tdist\n  * F: fdist\n  * Chi Square: chisq\n  * Binomial: bino\n  * Hypergeometric: hypg\n  * Exponential: expo\n  * Poisson: pois\n  * Beta: beta\n  * Gamma: gamma\n  * LogNormal: lognormal\n  * Uniform: unif\n\n## Roadmap\n\nThis gem wasn't updated for a long time before I started working on it, so there are a lot of work to do. The first priority is cleaning the interface and removing cruft whenever possible. After that, I want to implement more distributions and make sure that each one has a RNG.\n\n### Short-term\n\n- Define a minimal interface for continuous and discrete distributions (e.g. mean, variance, mode, skewness, kurtosis, pdf, cdf, quantile, cquantile).\n- Implement `Distribution::Uniform` with the default Ruby `Random`.\n- Clean up the implementation of normal distribution. Implement the necessary functions.\n- The same for Student's t, chi square, Fisher-Snedecor, beta, gamma, lognormal, logistic.\n- The same for discrete distributions: binomial, hypergeometric, bernoulli (still missing), etc.\n\n### Medium-term\n\n- Implement [DSFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/) for the uniform random generator.\n- Cauchy distribution.\n\n### Long-term\n\n- Implementing everything in the distributions x functions table above.\n\n## Issues\n\n* On JRuby and Rubinius, BivariateNormal returns incorrect pdf\n\nFor current issues see the [issue tracker pages](https://github.com/sciruby/distribution/issues).\n\n## OMG! I want to help!\n\nEveryone is welcome to help! Please, test these distributions with your own use\ncases and give a shout on the issue tracker if you find a problem or something\nis strange or hard to use. Documentation pull requests are totally welcome.\nMore generally, any ideas or suggestions are welcome -- even by private e-mail.\n\nIf you want to provide a new distribution, run `lib/distribution`:\n\n```\n$ distribution --new your_distribution\n```\n\nThis should create the main distribution file, the directory with Ruby and GSL engines and specs on the spec/ directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclbustos%2Fdistribution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclbustos%2Fdistribution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclbustos%2Fdistribution/lists"}