Comparing version 0.1.0 to 0.1.1
@@ -1,1 +0,1 @@ | ||
var version = "0.1.0"; export * from "../index"; export {version}; | ||
var version = "0.1.1"; export * from "../index"; export {version}; |
@@ -60,3 +60,3 @@ (function (global, factory) { | ||
var version = "0.1.0"; | ||
var version = "0.1.1"; | ||
@@ -63,0 +63,0 @@ exports.version = version; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("d3-random",["exports"],t):t(n.d3_random={})}(this,function(n){"use strict";function t(n,t){var r=arguments.length;return r?1===r?(t=+n,n=0):(n=+n,t=+t-n):(n=0,t=1),function(){return Math.random()*t+n}}function r(n,t){var r=arguments.length;return r?1===r?(n=+n,t=1):(n=+n,t=+t):(n=0,t=1),function(){var r,e,o;do r=2*Math.random()-1,e=2*Math.random()-1,o=r*r+e*e;while(!o||o>1);return n+t*r*Math.sqrt(-2*Math.log(o)/o)}}function e(){var n=r.apply(this,arguments);return function(){return Math.exp(n())}}function o(n){return function(){for(var t=0,r=0;n>r;++r)t+=Math.random();return t}}function u(n){var t=o(n);return function(){return t()/n}}function a(n){return function(){return-Math.log(1-Math.random())/n}}var i="0.1.0";n.version=i,n.uniform=t,n.normal=r,n.logNormal=e,n.bates=u,n.irwinHall=o,n.exponential=a}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("d3-random",["exports"],t):t(n.d3_random={})}(this,function(n){"use strict";function t(n,t){var r=arguments.length;return r?1===r?(t=+n,n=0):(n=+n,t=+t-n):(n=0,t=1),function(){return Math.random()*t+n}}function r(n,t){var r=arguments.length;return r?1===r?(n=+n,t=1):(n=+n,t=+t):(n=0,t=1),function(){var r,e,o;do r=2*Math.random()-1,e=2*Math.random()-1,o=r*r+e*e;while(!o||o>1);return n+t*r*Math.sqrt(-2*Math.log(o)/o)}}function e(){var n=r.apply(this,arguments);return function(){return Math.exp(n())}}function o(n){return function(){for(var t=0,r=0;n>r;++r)t+=Math.random();return t}}function u(n){var t=o(n);return function(){return t()/n}}function a(n){return function(){return-Math.log(1-Math.random())/n}}var i="0.1.1";n.version=i,n.uniform=t,n.normal=r,n.logNormal=e,n.bates=u,n.irwinHall=o,n.exponential=a}); |
{ | ||
"name": "d3-random", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Generate random numbers from various distributions.", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"d3-arrays": "~0.3.1", | ||
"d3-array": "~0.6.1", | ||
"faucet": "0.0", | ||
@@ -31,0 +31,0 @@ "rollup": "0.20.5", |
@@ -7,7 +7,13 @@ # d3-random | ||
If you use NPM, `npm install d3-random`. Otherwise, download the [latest release](https://github.com/d3/d3-random/releases/latest). | ||
If you use NPM, `npm install d3-random`. Otherwise, download the [latest release](https://github.com/d3/d3-random/releases/latest). The released bundle supports AMD, CommonJS, and vanilla environments. Create a custom build using [Rollup](https://github.com/rollup/rollup) or your preferred bundler. You can also load directly from [d3js.org](https://d3js.org): | ||
```html | ||
<script src="https://d3js.org/d3-random.v0.1.min.js"></script> | ||
``` | ||
In a vanilla environment, a `d3_random` global is exported. [Try d3-random in your browser.](https://tonicdev.com/npm/d3-random) | ||
## API Reference | ||
<a name="uniform" href="#uniform">#</a> <b>uniform</b>([<i>min</i>, ][<i>max</i>]) | ||
<a name="uniform" href="#uniform">#</a> d3_random.<b>uniform</b>([<i>min</i>, ][<i>max</i>]) | ||
@@ -17,4 +23,4 @@ Returns a function for generating random numbers with a [uniform distribution](https://en.wikipedia.org/wiki/Uniform_distribution_\(continuous\)). 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: | ||
```js | ||
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. | ||
d3_random.uniform(6)(); // Returns a number greater than or equal to 0 and less than 6. | ||
d3_random.uniform(1, 5)(); // Returns a number greater than or equal to 1 and less than 5. | ||
``` | ||
@@ -24,26 +30,20 @@ | ||
<a name="normal" href="#normal">#</a> <b>normal</b>([<i>mu</i>][, <i>sigma</i>]) | ||
<a name="normal" href="#normal">#</a> d3_random.<b>normal</b>([<i>mu</i>][, <i>sigma</i>]) | ||
Returns a function for generating random numbers with a [normal (Gaussian) distribution](https://en.wikipedia.org/wiki/Normal_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. | ||
<a name="logNormal" href="#logNormal">#</a> <b>logNormal</b>([<i>mu</i>][, <i>sigma</i>]) | ||
<a name="logNormal" href="#logNormal">#</a> d3_random.<b>logNormal</b>([<i>mu</i>][, <i>sigma</i>]) | ||
Returns a function for generating random numbers with a [log-normal distribution](https://en.wikipedia.org/wiki/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. | ||
<a name="bates" href="#bates">#</a> <b>bates</b>(<i>n</i>) | ||
<a name="bates" href="#bates">#</a> d3_random.<b>bates</b>(<i>n</i>) | ||
Returns a function for generating random numbers with a [Bates distribution](https://en.wikipedia.org/wiki/Bates_distribution) with *n* independent variables. | ||
<a name="irwinHall" href="#irwinHall">#</a> <b>irwinHall</b>(<i>n</i>) | ||
<a name="irwinHall" href="#irwinHall">#</a> d3_random.<b>irwinHall</b>(<i>n</i>) | ||
Returns a function for generating random numbers with an [Irwin–Hall distribution](https://en.wikipedia.org/wiki/Irwin–Hall_distribution) with *n* independent variables. | ||
<a name="exponential" href="#exponential">#</a> <b>exponential</b>(<i>lambda</i>) | ||
<a name="exponential" href="#exponential">#</a> d3_random.<b>exponential</b>(<i>lambda</i>) | ||
Returns a function for generating random numbers with an [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with the rate *lambda*; equivalent to time between events in a [Poisson process](https://en.wikipedia.org/wiki/Poisson_point_process) with a mean of 1 / *lambda*. For example, exponential(1/40) generates random times between events where, on average, one event occurs every 40 units of time. | ||
## Changes from D3 3.x: | ||
* Added a [uniform](#uniform) random number generator. | ||
* Added an [exponential](#exponential) random number generator. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10522