About
mctad.js is a JavaScript library for probability and statistics. It was created to provide functionality missing from other such libraries — such as having an awareness of many common discrete and continuous probability distributions, and the ability to generate random variables from those distributions — although it also provides a growing list of standard descriptive statistics and statistical analyses.
Descriptive Statistics
Given an Array of data, mctad.js can calculate its
arithmetic_mean(Array)
, aliased asmean(Array)
geometric_mean(Array)
median(Array)
mode(Array)
, always returned as an Array, if definedsample_variance(Array)
sample_standard_deviation(Array)
There are also public methods for sum
and product
.
> data = [1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 12, 12, 17];
[1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 12, 12, 17]
> mctad.sum(data);
107
> mctad.mean(data);
8.23076923076923
> mctad.median(data);
7
> mctad.mode(data);
[6, 12]
When defined and non-trivial to implement, descriptive statistics are returned with any probability distribution objects you create.
Confidence Intervals
mctad.js can create one- and two-tailed confidence intervals on the:
- population mean
- proportion
- difference between two means
- difference between two proportions
Probability Distributions
mctad.js can create many common discrete and continuous probability distributions from parameters you supply. The resulting probability distribution objects contain common statistics on the distribution (when defined); convenience methods for accessing probability distribution, probability mass, and cumulative probability functions; domain & range helpers to simplify integration with D3, and random variable generators.
- Discrete Probability Distributions
- Continuous Probability Distributions
Core and Helpers
mctad.js has a number of methods, included in /src/core
. mctad.js uses them internally, but they are available for your use, and include
isInteger()
allPositive(Array)
sortNumeric(Array)
toRadians(v)
getBaseLog(x, y)
getRandomArbitrary(min, max)
getRandomInt(min, max)
factorial(n)
doubleFactorial(n)
combination(n, k)
Γ(n)
, aliased asgamma(n)
Documentation for these is interspersed with the code, meaning the Groc-generated documentation is the best place to see how they’re implemented and to learn what they do.
Documentation
Groc-generated documentation is available here and in the /doc directory of your cloned repository.