distributions.io
v0.0.1
Published
Collection of probability distributions.
Downloads
7
Readme
Distributions
Collection of probability distributions.
This modules provides functions to evaluate the CDF, PDF / PMF and quantile functions for a wide range of discrete and continuous probability distributions. In addition, it implements random number generators, moment-generating functions and facilities to retrieve distribution properties such as the moments of the respective distribution.
Installation
$ npm install distributions.io
Usage
var dist = require( 'distributions.io' );
Common Interface
Distributions
- Discrete Distributions
- .binom (Binomial)
- .geom (Geometric)
- .hypergeom (Hypergeometric)
- .nbinom (Negative binomial)
- .pois (Poisson)
- Continuous Distributions
- .beta (Beta)
- .cauchy (Cauchy)
- .chisq (Chi-Squared)
- .erlang (Erlang)
- .exp (Exponential)
- .f (Fisher's F)
- .gamma (Gamma)
- .gumbel (Gumbel)
- .invgamma (Inverse-Gamma)
- .laplace (Laplace)
- .logistic (Logistic)
- .lnorm (Log-Normal)
- .rayleigh (Rayleigh)
- .t (Student T)
- .unif (Continuous Uniform)
- .norm (Normal)
- .pareto (Pareto Type I)
- .triangular (Triangular)
- .weibull (Weibull)
Examples
var dist = require( 'distributions.io' ),
out;
// Generate 30 standard normal random variates:
out = dist.norm.random( 30 );
// Evaluate the PDF of a exponential distribution with lambda=2 at 0:
out = dist.exp.pdf( 0, {lambda: 2} );
// Retrieve the excess kurtosis of a Poisson random variable with lambda = 3:
out = dist.poisson.ekurtosis( 3 );
// Evaluate the CDF of a standard normal for an array of values:
out = dist.norm.cdf( [-3,-2,-1,0,1,2,3] );
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015. The Distributions.io Authors.