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 🙏

© 2026 – Pkg Stats / Ryan Hefner

normadist

v1.0.3

Published

A lightweight TypeScript package used to model normal distributions

Readme

normadist

A lightweight TypeScript package used to model Normal Distributions.

⬇️ Installing

For the latest stable version:

npm install normadist

🔎 API

In this section is presented hwo to use our library concisely.

First Steps to use the Normal Distribution

To use a normal distribution the library user can do the right below little piece of code.

If it has been using JavaScript

const { NormalDistribution } = require('normadist');

// Instantiating the standard normal distribution.
const distribution = NormalDistribution.standard();

// Printing the cumulative distribution function evaluated at 0.2
console.log(distribution.cdf(0.2));

If it has been using TypeScript

import { NormalDistribution } from 'normadist';

// Instantiating the standard normal distribution.
const distribution = NormalDistribution.standard();

// Printing the cumulative distribution function evaluated at 0.2
console.log(distribution.cdf(0.2));

Class Members

It will be shown the class members that the NormalDistribution class provides for the users.

  • mean: The mean of the normal distribution.
  • standardDeviation: The standard deviation of the normal distribution. That value must be a positive number.
  • erf: An approximation for the error function. The library already provides one, however, the library user can choose one of its preference. Nevertheless, the wrong implementation for that error function approximation can lead errors for the values returned by the functions, since most of the functions use in its implementations the error function.

Class Methods

It will be shown the class methods that the NormalDistribution class provides for the users.

#pdf(x)

The pdf stands for probability density function that when is evaluated at a point x returns the probability of the normal random variable X takes the value x.

#cdf(x)

The cdf stands for cumulative distribution function that when is evaluated at a point x returns the value that represents the area below the probability density function from -Infinity to x.

#ppf(x[, ierfc])

The ppf stands for percent point function that represents the inverse cumulative distribution function, then when it is evaluated at a point x the value returned represents the point at the horizontal axis, such that, all area below the probability density function at left of that value is x.

:warning: Warning: The second parameter ierfc is already implemented by default. However, the user can choose one of its preferece. Altough, the wrong implementation of the inverse of complementary error function can lead to errors.

#between(startInterval, endInterval)

The between returns the value of the probability of the normal distributed random variable X take one of the values in the real, closed interval [startInterval, endInterval].

#standardize(x)

The standardize receives a value x and returns the standardized value z.

#random(x)

The random returns a random generated number in that normal distribution.

:bulb: Behind the scenes: This random number generator uses the Marsaglia Polar Method.

#variance()

The variance returns the variance of that normal distribution.

static #standard([erf])

Returns a standard normal distribution, that is, the normal distribution with mean equals to 0 and standard deviation equals to 1.

:warning: Warning: There is the erf parameter that is implemented by default, that represents the error function approximation. However, the user can choose one of its preference. Altough, the wrong implementation of the error function can lead to errors.

static #of(mean, standardDeviation[, erf])

Returns a normal distribution with specified mean and standardDeviation. Further, the user can still specify the implementation of the error function. However, this it is not recommended.

static #isNormalDistributed(cdf, mean, standardDeviation[, tolerance])

Returns true if the distribution specified by the cumulative distribution function is approximately normal distributed. Otherwise, false is returned. Furthermore, the tolerance can be adjusted, such that, the reliability about cdf is adjusted.