Comparing version 0.0.2 to 0.0.3
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
var irwinHall = function(n) { | ||
function irwinHall(n) { | ||
return function() { | ||
@@ -13,5 +13,5 @@ for (var sum = 0, i = 0; i < n; ++i) sum += Math.random(); | ||
}; | ||
} | ||
}; | ||
var bates = function(n) { | ||
function bates(n) { | ||
var randomIrwinHall = irwinHall(n); | ||
@@ -21,5 +21,5 @@ return function() { | ||
}; | ||
} | ||
}; | ||
var normal = function(mu, sigma) { | ||
function normal(mu, sigma) { | ||
var n = arguments.length; | ||
@@ -38,5 +38,5 @@ if (!n) mu = 0, sigma = 1; | ||
}; | ||
} | ||
}; | ||
var logNormal = function() { | ||
function logNormal() { | ||
var randomNormal = normal.apply(this, arguments); | ||
@@ -46,5 +46,5 @@ return function() { | ||
}; | ||
} | ||
}; | ||
var uniform = function(min, max) { | ||
function uniform(min, max) { | ||
var n = arguments.length; | ||
@@ -57,3 +57,3 @@ if (!n) min = 0, max = 1; | ||
}; | ||
} | ||
}; | ||
@@ -60,0 +60,0 @@ exports.uniform = uniform; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.random={})}(this,function(n){"use strict";var t=function(n){return function(){for(var t=0,r=0;n>r;++r)t+=Math.random();return t}},r=function(n){var r=t(n);return function(){return r()/n}},e=function(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)}},o=function(){var n=e.apply(this,arguments);return function(){return Math.exp(n())}},u=function(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}};n.uniform=u,n.normal=e,n.logNormal=o,n.bates=r,n.irwinHall=t}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.random={})}(this,function(n){"use strict";function t(n){return function(){for(var t=0,r=0;n>r;++r)t+=Math.random();return t}}function r(n){var r=t(n);return function(){return r()/n}}function e(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 o(){var n=e.apply(this,arguments);return function(){return Math.exp(n())}}function u(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}}n.uniform=u,n.normal=e,n.logNormal=o,n.bates=r,n.irwinHall=t}); |
{ | ||
"name": "d3-random", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Generate random numbers from various distributions.", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
}, | ||
"main": "build/random", | ||
"main": "build/random.cjs", | ||
"jsnext:main": "index", | ||
@@ -24,14 +24,14 @@ "repository": { | ||
"scripts": { | ||
"pretest": "mkdir -p build && d3-bundler --format=umd --name=random -- index.js > build/random.js", | ||
"pretest": "mkdir -p build && d3-bundler -x -f cjs -o build/random.cjs.js", | ||
"test": "faucet `find test -name '*-test.js'`", | ||
"prepublish": "npm run test && uglifyjs build/random.js -c -m -o build/random.min.js && rm -f build/random.zip && zip -j build/random.zip -- LICENSE README.md build/random.js build/random.min.js" | ||
"prepublish": "npm run test && d3-bundler -n random -o build/random.js && uglifyjs build/random.js -c -m -o build/random.min.js && rm -f build/random.zip && zip -j build/random.zip -- LICENSE README.md build/random.js build/random.min.js" | ||
}, | ||
"devDependencies": { | ||
"d3-arrays": "~0.0.3", | ||
"d3-bundler": "~0.2.6", | ||
"d3-arrays": "~0.1.2", | ||
"d3-bundler": "~0.4.0", | ||
"faucet": "0.0", | ||
"seedrandom": "2", | ||
"tape": "4", | ||
"uglifyjs": "2" | ||
"uglify-js": "2" | ||
} | ||
} |
@@ -5,6 +5,8 @@ # d3-random | ||
Changes from D3 3.x: | ||
## Installing | ||
* Added a [uniform](#uniform) random number generator. | ||
If you use NPM, `npm install d3-random`. Otherwise, download the [latest release](https://github.com/d3/d3-random/releases/latest). | ||
## API Reference | ||
<a name="uniform" href="#uniform">#</a> <b>uniform</b>([<i>min</i>, ][<i>max</i>]) | ||
@@ -36,1 +38,5 @@ | ||
Returns a function for generating random numbers with an [Irwin–Hall distribution](https://en.wikipedia.org/wiki/Irwin–Hall_distribution) with *n* independent variables. | ||
## Changes from D3 3.x: | ||
* Added a [uniform](#uniform) 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
9974
13
155
41