explaingit

stdlib-js/stdlib

5,830JavaScriptAudience · dataComplexity · 3/5Setup · easy

TLDR

A massive standard library for JavaScript and TypeScript that brings numerical and scientific computing tools, math functions, probability distributions, and random number generators, to both browsers and Node.js.

Mindmap

mindmap
  root((stdlib))
    What it does
      Scientific computing in JS
      Math functions library
      Stats and probability
    Math Coverage
      150 plus special functions
      35 plus distributions
      40 plus random generators
    Design
      Fully decomposable packages
      TypeScript declarations
      Native C add-ons optional
    Usage
      Node.js and browser
      REPL environment
      npm individual packages
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Do advanced mathematical calculations in JavaScript, gamma functions, Bessel functions, and other special math, without switching to Python or R.

USE CASE 2

Generate random numbers from specific probability distributions with configurable seeds for reproducible simulations in the browser or Node.js.

USE CASE 3

Build data analysis or statistics tools in JavaScript using a consistent, well-typed library with TypeScript autocomplete support.

USE CASE 4

Install only the individual math functions you need from npm as tiny separate packages rather than one large monolithic library.

Tech stack

JavaScriptTypeScriptNode.jsCnpmWebpackBrowserify

Getting it running

Difficulty · easy Time to first run · 30min

Install individual packages from npm rather than one large bundle, TypeScript types are included for all functions.

License information was not mentioned in the explanation.

In plain English

stdlib is a comprehensive standard library for JavaScript and TypeScript focused on numerical and scientific computing. It brings to JavaScript much of the mathematical functionality you would expect from specialized languages like Python with NumPy, R, or MATLAB, making it possible to do serious number crunching in a browser or in Node.js without switching languages. The library covers a wide range of mathematical tools. It includes over 150 special math functions (things like gamma functions, Bessel functions, and other advanced calculations), more than 35 probability distributions with support for probability density functions, cumulative distribution functions, and quantiles, and over 40 random number generators with configurable seeds. It also includes tools for statistics, data transformation, functional programming, input validation, a plotting API for visualizing data, and over 50 sample datasets for testing and development. A core design goal is full decomposability. Rather than one large package, the library is split into thousands of small individual packages, each available separately on npm. You install only what you need. TypeScript declaration files are provided for every function, which means your code editor can offer accurate autocomplete suggestions. Many of the core math routines also have native C add-ons for performance, with pure JavaScript fallbacks when those are not available. The library can run in Node.js or be bundled for browser use with standard tools like Webpack or Browserify. It includes an interactive REPL environment for experimenting with functions directly, a built-in benchmarking framework, and extensive documentation. Installation is via npm, and the project maintains an active community with public office hours, a Zulip chat, and financial support through Open Collective. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
I want to use stdlib-js to compute a normal distribution CDF in JavaScript. Show me how to install the specific package and use it in a Node.js script.
Prompt 2
How do I use stdlib-js's random number generators with a fixed seed so my simulation produces the same output every run?
Prompt 3
I want to compute basic descriptive statistics on an array of numbers using stdlib-js, mean, variance, and standard deviation. Which packages do I install and how do I use them?
Prompt 4
Can I use stdlib-js in a browser project bundled with Webpack? How do I install and import only the specific functions I need to keep bundle size small?
Open on GitHub → Explain another repo

← stdlib-js on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.