essy-distribution
Distributions and random sampling.
Last updated 3 years ago by scherry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install essy-distribution 
SYNC missed versions from official npm registry.

Javascript Distributions and Sampling

Installation

npm install essy-distribution

Description

Defines multiple distributions with methods for random sampling and calculating distribution properties. Sampling functions are largely ported from CERN's cern.jet.random Java package. See the source code for details.

This package was created during the development of Essy Tree to support Monte Carlo simulations.

Basic Usage (node.js)

var dists  = require('essy-distribution');

var normal = new dists.Normal(0, 1);
var mean   = normal.mean();     // 0
var sample = normal.sample();   // eg, 0.2314311234

Basic Usage (ES2015)

import { Normal } from 'essy-distribution';

var normal = new Normal(0, 1);
var mean   = normal.mean();     // 0
var sample = normal.sample();   // eg, 0.2314311234

Or you can load the entire package:

import * as dists from 'essy-distribution';

var normal = new dists.Normal(0, 1);
var mean   = normal.mean();     // 0
var sample = normal.sample();   // eg, 0.2314311234

Each distribution defines the following methods:

cdf(x {Number})

Cumulative distribution function.

mean()

Returns distribution mean.

median()

Returns distribution median.

pdf(x {Number})

Probability density function.

sample([n {Number}] [,generator {Object}])

Samples the distribution. If no arguments are provided or n = 1 a single sampled value is returned. If n is greater than 1, an array of n sampled values is returned.

The method accepts an optional generator object that defines a method random(). If no generator is provided a mersenne-twister is used.

variance()

Returns variance.

Distributions

Beta(alpha, beta)

See documentation.

Binomial(samples, probability)

See documentation.

Cauchy(location, scale)

See article.

ChiSquared(degreesOfFreedom)

See article.

Custom(values)

A custom distribution. The values argument should be an array of numbers.

Erlang(shape, rate)

See documentation.

Exponential(lambda)

See documentation.

F(degreesOfFreedom1, degreesOfFreedom2)

See article.

Gamma(shape, scale)

See documentation.

Hypergeometric(N, K, n)

See article.

Laplace(location, scale)

See documentation.

Levy(location, scale)

See article.

Logarithmic(probability)

See documentation.

Logistic(mean, scale)

See documentation.

LogLogistic(scale, shape)

See documentation.

LogNormal(mean, se)

See documentation.

Normal(mean, se)

See documentation.

Pareto(scale, shape)

See article.

Poisson(lambda)

See documentation.

Rayleigh(scale)

See documentation.

StudentT(degreesOfFreedom)

See article.

Triangular(min, mode, max)

See documentation.

Uniform(min, max)

See documentation.

Weibull(shape, scale)

See documentation.

Current Tags

  • 1.1.22                                ...           latest (3 years ago)

60 Versions

  • 1.1.22                                ...           3 years ago
  • 1.1.21                                ...           3 years ago
  • 1.1.20                                ...           3 years ago
  • 1.1.19                                ...           3 years ago
  • 1.1.18                                ...           3 years ago
  • 1.1.17                                ...           3 years ago
  • 1.1.16                                ...           3 years ago
  • 1.1.15                                ...           3 years ago
  • 1.1.14                                ...           3 years ago
  • 1.1.13                                ...           3 years ago
  • 1.1.12                                ...           3 years ago
  • 1.1.11                                ...           3 years ago
  • 1.1.10                                ...           3 years ago
  • 1.1.9                                ...           3 years ago
  • 1.1.8                                ...           3 years ago
  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.5                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.28                                ...           3 years ago
  • 1.0.279                                ...           3 years ago
  • 1.0.278                                ...           3 years ago
  • 1.0.277                                ...           3 years ago
  • 1.0.276                                ...           3 years ago
  • 1.0.275                                ...           3 years ago
  • 1.0.274                                ...           3 years ago
  • 1.0.273                                ...           3 years ago
  • 1.0.272                                ...           3 years ago
  • 1.0.271                                ...           3 years ago
  • 1.0.27                                ...           3 years ago
  • 1.0.26                                ...           3 years ago
  • 1.0.25                                ...           3 years ago
  • 1.0.24                                ...           3 years ago
  • 1.0.23                                ...           3 years ago
  • 1.0.22                                ...           3 years ago
  • 1.0.21                                ...           3 years ago
  • 1.0.20                                ...           3 years ago
  • 1.0.19                                ...           3 years ago
  • 1.0.18                                ...           3 years ago
  • 1.0.17                                ...           3 years ago
  • 1.0.16                                ...           3 years ago
  • 1.0.15                                ...           3 years ago
  • 1.0.14                                ...           3 years ago
  • 1.0.13                                ...           3 years ago
  • 1.0.12                                ...           3 years ago
  • 1.0.10                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |