thii / binomjs

A binomial distribution testing library in JavaScript
MIT License
4 stars 0 forks source link

binomjs CI Status

A binomial distribution testing library in JavaScript.

Installation

npm install binomjs
component install thii/binomjs

Building component

npm install uglify-js -g
component install
component build -n binom
uglifyjs build/binom.js -o build/binom.min.js

The built version of binomjs will be put in the build/ subdirectory.

Example

var Binom = require('binomjs');
var binom = new Binom();

// binom.test(trialsNum, successesNum, hypothesisTrialsNum, hypothesisSuccessesNum, confidenceRate)
var result = binom.test(1000, 100, 1000, 50, 0.95);
/*
{ averageSuccessRate: 0.1,
  minSuccessRate: 0.0814,
  maxSuccessRate: 0.1186,
  pValue: 0.024997895303140116,
  testResult: true,
  error: undefined }
*/

The above example run in R:

binom.test(100, 1000, p = 0.95, alternative = c("two.sided"), conf.level = 0.95)

Result in R:

    Exact binomial test

data:  100 and 1000
number of successes = 100, number of trials = 1000, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.95
95 percent confidence interval:
 0.08210533 0.12028794
sample estimates:
probability of success 
                   0.1 

Running Tests

npm install
npm test

License

MIT