{"id":19644942,"url":"https://github.com/quantecon/rvlib","last_synced_at":"2026-03-05T02:04:31.535Z","repository":{"id":46390877,"uuid":"60223789","full_name":"QuantEcon/rvlib","owner":"QuantEcon","description":"Distributions for Python","archived":false,"fork":false,"pushed_at":"2022-01-13T17:33:02.000Z","size":1509,"stargazers_count":48,"open_issues_count":8,"forks_count":11,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-11-10T04:32:07.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://quantecon.github.io/rvlib/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QuantEcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-02T01:48:20.000Z","updated_at":"2025-03-06T23:20:36.000Z","dependencies_parsed_at":"2022-09-26T17:51:29.766Z","dependency_job_id":null,"html_url":"https://github.com/QuantEcon/rvlib","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/QuantEcon/rvlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuantEcon%2Frvlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuantEcon%2Frvlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuantEcon%2Frvlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuantEcon%2Frvlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuantEcon","download_url":"https://codeload.github.com/QuantEcon/rvlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuantEcon%2Frvlib/sbom","scorecard":{"id":115906,"data":{"date":"2025-08-11","repo":{"name":"github.com/QuantEcon/rvlib","commit":"6a0b896fdebd86d67bf307f44f59fc3493dcea34"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/unittests.yml:1","Warn: no topLevel permission defined: .github/workflows/upload_package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittests.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/unittests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittests.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/unittests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/unittests.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/unittests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/upload_package.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/upload_package.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/upload_package.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/upload_package.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/upload_package.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/upload_package.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/QuantEcon/rvlib/upload_package.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/upload_package.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/upload_package.yml:22","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T01:16:40.339Z","repository_id":46390877,"created_at":"2025-08-16T01:16:40.339Z","updated_at":"2025-08-16T01:16:40.339Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30106186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11T14:31:05.398Z","updated_at":"2026-03-05T02:04:31.512Z","avatar_url":"https://github.com/QuantEcon.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"## `rvlib`\n\nAnyone who has used [`Distributions.jl`](https://github.com/JuliaStats/Distributions.jl) will tell\nyou how nice the interface is relative to the \"exotic\" (the most polite word\nwe can think of) interface to distributions exposed by\n[scipy.stats](http://docs.scipy.org/doc/scipy-0.17.1/reference/stats.html).\n`Distributions.jl` also brings better performance, particularly when its\nmethods are used inside loops.\n\nFor these reason we've put together `rvlib`, which mimics the\ninterface of [`Distributions.jl`](https://github.com/JuliaStats/Distributions.jl), while at the same\ntime attaining similar performance by exploiting [`numba`](http://numba.pydata.org/).\n\nThis package was inspired by Joshua Adelman's ([@synapticarbors](https://github.com/synapticarbors)) \n[blog post](https://www.continuum.io/blog/developer-blog/calling-c-libraries-numba-using-cffi) describing how \nto call the Rmath C library from numba using [CFFI](http://cffi.readthedocs.io/), and utilizes his build script \nto set up the CFFI interface.\n\n### Objectives\n\n* Follow the API of the `Distributions.jl` package as closely as possible \n\n* Create a python package that has better performance than `scipy.stats`. \n\n### Methodology\n\nAll the classes are marked for optimization using the `@jitclass` decorator. As a result, instances of different distributions can be called within user specific routines or passed as arguments in `nopython` mode using `numba`.\n\nThe evaluation and sampling methods are built on the `Rmath` C library -- also used by the `Distributions.jl` package.\n\n### Distributions currently implemented\n\nUnivariate continuous:\n\n* Normal\n* Chisq\n* Uniform\n* T\n* Log-normal\n* F\n* Beta\n* Gamma\n* Exponential\n* Cauchy\n* Logistic\n* Weibull\n\nUnivariate discrete:\n\n* Poisson\n* Geometric\n* Hypergeometric\n* Binomial\n* Negative Binomial\n\n\nMultivariate continuous:\n\n* check for updates on mulitvariate normal in `multivariate` branch\n\n### Functionality\n\nThe following properties are shared by all the univariate distributions:\n\n* `params`: tuple of the distribution's parameters\n* `location`: the location of the distribution (if exists)\n* `scale`: the scale of the distribution (if exists)\n* `shape`: the shape of the distribution (if exists)\n* `mean`: the mean of the distribution\n* `median`: the median of the distribution\n* `mode`: the mode of the distribution\n* `var`: the variance of the distribution\n* `std`: the standard deviation of the distribution\n* `skewness`: the skewness of the distribution\n* `kurtosis`: the kurtosis of the distribution\n* `isplatykurtic`: boolean indicating if kurtosis is greater than zero\n* `isleptokurtic`: boolean indicating if kurtosis is less than zero\n* `ismesokurtic`: boolean indicating if kurtosis is equal to zero\n* `entropy`: the entropy of the distribution\n\nThe following methods can be called for all univariate distributions:\n\n* `mgf`: evaluate the moment generating function (if exists)\n* `cf`: evaluate the characteristic function (if exists)\n* `pdf`: evaluate the probability density function\n* `logpdf`: evaluate the logarithm of the prabability density function\n* `loglikelihood`: evaluate the log-likelihood of the distribution with respect to all samples contained in array x\n* `cdf`: evaluate the cumulative distribution function\n* `ccdf`: evaluate the complementary cdf, i.e. (1 - cdf)\n* `logcdf`: evaluate the logarithm of the cdf\n* `logccdf`: evaluate the logarithm of the complementary cdf\n* `quantile`: evaluate the quantile function at a critical value\n* `cquantile`: evaluate the complementary quantile function\n* `invlogcdf`: evaluate the inverse function of the logcdf\n* `invlogccdf`: evaluate the inverse function of the logccdf\n* `rand`: generate array of independent random draws\n\nSeed setting\n\nAs the package is built around the `Rmath` library the seed for the random number generator has to be set using the `Rmath` `set_seed(x,y)` function. For example:\n\n```python\nimport rvlib as rl\n\nrl.set_seed(123, 456) # note that it requires two arguments\n```\n\n\n### Use and Performance\n\nPreliminary comparison with the `scipy.stats` package.\n\n```python\nfrom rvlib import Normal\nfrom scipy.stats import norm\nimport numpy as np\nimport timeit\n\nN_dist = Normal(0,1) # rvlib version\nN_scipy = norm(0,1) # scipy.stats version\n\nx = np.linspace(0,100,100)\n```\n\n\n```python\nIn [1]: %timeit N_dist.pdf(x)\nOut[1]: The slowest run took 8.85 times longer than the fastest. This could mean that an intermediate result is being cached.\n    100000 loops, best of 3: 9.69 µs per loop\n    \nIn [2]: %timeit N_scipy.pdf(x)\nOut[2]: 10000 loops, best of 3: 150 µs per loop\n```\n\n\n```python\nIn [3]: %timeit N_dist.cdf(x)\nOut[3]: The slowest run took 20325.82 times longer than the fastest. This could mean that an intermediate result is being cached.\n    100000 loops, best of 3: 8.08 µs per loop\n\nIn [4]: %timeit N_scipy.cdf(x)\nOut[4]:The slowest run took 190.64 times longer than the fastest. This could mean that an intermediate result is being cached.\n    10000 loops, best of 3: 126 µs per loop\n```\n\n\n```python\nIn [5]: %timeit N_dist.rand(1000)\nOut[5]: The slowest run took 2166.80 times longer than the fastest. This could mean that an intermediate result is being cached.\n    10000 loops, best of 3: 85.8 µs per loop\n    \nIn [6]: %timeit N_scipy.rvs(1000)\nOut[6]: 10000 loops, best of 3: 119 µs per loop\n```\n\n\n# Contributors\n\n* Daniel Csaba (daniel.csaba@nyu.edu)\n* Spencer Lyon (spencer.lyon@stern.nyu.edu)\n* Eli Knaap (ek@knaaptime.com)\n\n---\n\nThis is a fork of the [Rmath-julia](https://github.com/JuliaLang/Rmath-julia)\nlibrary, with Python support added.\n\nThe original readme of the Rmath-julia repository is included below.\n\n---\n\n## Rmath-julia\n\nThis is the Rmath library from R, which is used mainly by Julia's\n[Distributions.jl](https://github.com/JuliaStats/Distributions.jl)\npackage.\n\nThe main difference here is that this library has been patched to use\nthe [DSFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/) RNG\nin `src/runif.c`.\n\nThe Julia RNG is in sync with the one used by the Distributions.jl package:\n\n````\njulia\u003e srand(1);\n\njulia\u003e [rand(), rand()]\n2-element Array{Float64,1}:\n 0.236033\n 0.346517\n\njulia\u003e srand(1);\n\njulia\u003e using Distributions\n\njulia\u003e [rand(Uniform()), rand(Uniform())]\n2-element Array{Float64,1}:\n 0.236033\n 0.346517\n````\n\n### Build instructions\n\nRmath-julia requires GNU Make (https://www.gnu.org/software/make). Just run\n`make` to compile the library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantecon%2Frvlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantecon%2Frvlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantecon%2Frvlib/lists"}