npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

essy-distribution

v1.1.34

Published

Distributions and random sampling.

Downloads

125

Readme

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.