This is the GitHub repository of stdlib source code and documentation. For help developing stdlib, see the development guide.
150+ special math functions.
35+ probability distributions, with support for evaluating probability density functions (PDFs), cumulative distribution functions (CDFs), quantiles, moments, and more.
40+ seedable pseudorandom number generators (PRNGs).
200+ general utilities for data transformation, functional programming, and asynchronous control flow.
200+ assertion utilities for data validation and feature detection.
50+ sample datasets for testing and development.
A plot API for data visualization and exploratory data analysis.
A benchmark framework supporting TAP.
REPL environment with integrated help and examples.
To accommodate various use cases, stdlib can be consumed in multiple ways. The preferred means of consumption depends on your individual use case. We've provided some user stories to help you identify the best approach.
While this project's installation instructions defaults to using npm for package management, installation via other package managers, such as yarn, should be a matter of simply swapping out npm commands with those of the relevant package manager.
- Install the entire project as a command-line utility.
I am building a web application.
- Install individual packages. Installing the entire project is likely unnecessary and will lead to slower installation times.
I would like to vendor a custom bundle containing various stdlib functionality.
- Follow the steps for creating custom bundles.
I would like to include stdlib functionality by just using a
I am interested in using a substantial amount of functionality found in a top-level stdlib namespace and don't want to separately install hundreds of individual packages (e.g., if building an on-line calculator application and wanting all of stdlib's math functionality).
Install one or more top-level namespaces. Installing the entire project is likely unnecessary and will lead to slower installation times. Installing a top-level namespace is likely to mean installing functionality which will never be used; however, installing a top-level namespace is likely to be easier and less time-consuming than installing many individual packages separately.
When bundling, installing a top-level namespace should not be a concern, as individual functionality can still be independently required/imported. Project installation times may, however, be somewhat slower.
I am building a Node.js server application.
I am interested in using various functionality found in stdlib.
I am interested in using a substantial amount of functionality found in a top-level stdlib namespace and don't want to separately install hundreds of individual packages.
I am using Deno.
I would like to use stdlib functionality in an Observable notebook.
I want to hack at stdlib, possibly even creating customized builds to link to platform-specific native libraries (such as Intel's MKL or some other numerical library).
To install the entire project as a library or application dependency,
$ npm install @stdlib/stdlib
Once installed, stdlib packages can be individually required/imported to minimize load times and decrease bundle sizes. For example, to use
var ndarray = require( '@stdlib/ndarray/ctor' ); var arr = ndarray( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns <ndarray>
and to use
import ndarray from '@stdlib/ndarray/ctor'; var arr = ndarray( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns <ndarray>
stdlib is designed to allow decomposition of the main project into individual packages which can be independently consumed. Accordingly, users of the project can avoid installing all project functionality and only install the exact functionality they need.
To install individual packages, replace forward slashes
@stdlib/ with hyphens
-. For example,
$ npm install @stdlib/ndarray-ctor
Once installed, individual packages can be required/imported. For example, to use
var ndarray = require( '@stdlib/ndarray-ctor' ); var arr = ndarray( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns <ndarray>
and to use
import ndarray from '@stdlib/ndarray-ctor'; var arr = ndarray( [ [ 1, 2 ], [ 3, 4 ] ] ); // returns <ndarray>
stdlib is comprised of various top-level namespaces (i.e., collections of related functionality united by common themes). For example, to install all math functionality found in the top-level
$ npm install @stdlib/math
Once installed, packages within a top-level namespace can be individually required/imported to minimize load times and decrease bundle sizes. For example, to use
var sin = require( '@stdlib/math/base/special/sin' ); var v = sin( 3.14 ); // returns <number>
and to use
import sin from '@stdlib/math/base/special/sin'; var v = sin( 3.14 ); // returns <number>
Note: installing nested namespaces found within top-level namespaces (e.g.,
math/base) is not supported. Consider installing individual packages or the relevant top-level namespace.
To install globally for use as a command-line utility and/or use the REPL,
$ npm install -g @stdlib/stdlib
which will expose the
stdlib command. For example, to see available sub-commands
$ stdlib help
and to run the REPL
$ stdlib repl
$ npm install @stdlib/dist-math-base-special-flat
and then include the following
<script> tag in our HTML document
making sure to modify the script path based on the local installation directory.
If no recognized module system is present, one can access bundle contents in another
<script> tag via the global scope.
To create a custom bundle based on project needs,
navigate to the local installation directory.
run the following command to print help documentation for providing a list of stdlib package names to bundle
$ NODE_PATH=./lib/node_modules node ./bin/cli bundle-pkg-list -- -h
modify and run the above command with the list of packages to bundle
$ NODE_PATH=./lib/node_modules node ./bin/cli bundle-pkg-list -- <pkg> <pkg> <pkg> ...
Upon generating a bundle, the bundle can be loaded via a
<script> tag as described above for pre-built distributable UMD bundles.
Installing and running stdlib for use in Node.js requires the following prerequisites:
npm: package manager (version
> 2.7.0; if Node
< 1.0.0, version
< 4.0.0; if Node
<= 10.x.x, version
- GNU make: development utility and task runner
- GNU bash: an sh-compatible shell
gcc & g++ or Clang: C/C++ compilation and linking (g++ version
>= 4.8; clang version
>= 3.5, Xcode version
>=8.3.1on OS X)
gfortran: Fortran compilation and linking (version
While not required to run stdlib, the following dependencies are required for automatically downloading external libraries:
The following external libraries can be automatically downloaded and compiled from source using
First time contributor?
- See the contributing guidelines.
Already an expert?
Fork the repository.
Clone the forked repository
$ git clone --depth=1 https://github.com/<username>/stdlib.git
<username>is your GitHub username.
Navigate to the
$ cd stdlib
$ make install-node-modules
Initialize your stdlib development environment
$ make init
Copyright © 2016-2021. The Stdlib Authors.