Package Exports
- d3-random
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (d3-random) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
d3-random
Generate random numbers from various distributions.
Changes from D3 3.x:
- Added a uniform random number generator.
# uniform([min, ][max])
Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min, and the maximum is max. If min is not specified, it defaults to 0; if max is not specified, it defaults to 1. For example:
uniform(6)(); // Returns a number greater than or equal to 0 and less than 6.
uniform(1, 5)(); // Returns a number greater than or equal to 1 and less than 5.
Note that you can also use the built-in Math.random to generate uniform distributions directly. For example, to generate a random integer between 0 and 99 (inclusive), you can say Math.random() * 100 | 0
.
# normal([mu][, sigma])
Returns a function for generating random numbers with a normal (Gaussian) distribution. The expected value of the generated numbers is mu, with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1.
# logNormal([mu][, sigma])
Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variable’s natural logrithm is mu, with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1.
# bates(n)
Returns a function for generating random numbers with a Bates distribution with n independent variables.
# irwinHall(n)
Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables.