pax_global_header00006660000000000000000000000064131024107670014513gustar00rootroot0000000000000052 comment=e080dc81f00fa4cf1965b7edeb33ebcd6e411b04 d3-random-1.1.0/000077500000000000000000000000001310241076700132765ustar00rootroot00000000000000d3-random-1.1.0/.eslintrc000066400000000000000000000001631310241076700151220ustar00rootroot00000000000000parserOptions: sourceType: module extends: "eslint:recommended" rules: no-cond-assign: 0 semi: 2 d3-random-1.1.0/.gitignore000066400000000000000000000001001310241076700152550ustar00rootroot00000000000000*.sublime-workspace .DS_Store build/ node_modules npm-debug.log d3-random-1.1.0/.npmignore000066400000000000000000000000361310241076700152740ustar00rootroot00000000000000*.sublime-* build/*.zip test/ d3-random-1.1.0/LICENSE000066400000000000000000000027031310241076700143050ustar00rootroot00000000000000Copyright 2010-2016 Mike Bostock All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. d3-random-1.1.0/README.md000066400000000000000000000111441310241076700145560ustar00rootroot00000000000000# d3-random Generate random numbers from various distributions. ## Installing If you use NPM, `npm install d3-random`. Otherwise, download the [latest release](https://github.com/d3/d3-random/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-random.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: ```html ``` [Try d3-random in your browser.](https://runkit.com/npm/d3-random) ## API Reference # d3.randomUniform([min, ][max]) [<>](https://github.com/d3/d3-random/blob/master/src/uniform.js "Source") 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 d3.randomUniform(6)(); // Returns a number greater than or equal to 0 and less than 6. d3.randomUniform(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](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/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`. # d3.randomNormal([mu][, sigma]) [<>](https://github.com/d3/d3-random/blob/master/src/normal.js "Source") 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. # d3.randomLogNormal([mu][, sigma]) [<>](https://github.com/d3/d3-random/blob/master/src/logNormal.js "Source") 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 logarithm 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. # d3.randomBates(n) [<>](https://github.com/d3/d3-random/blob/master/src/bates.js "Source") Returns a function for generating random numbers with a [Bates distribution](https://en.wikipedia.org/wiki/Bates_distribution) with *n* independent variables. # d3.randomIrwinHall(n) [<>](https://github.com/d3/d3-random/blob/master/src/irwinHall.js "Source") Returns a function for generating random numbers with an [Irwin–Hall distribution](https://en.wikipedia.org/wiki/Irwin–Hall_distribution) with *n* independent variables. # d3.randomExponential(lambda) [<>](https://github.com/d3/d3-random/blob/master/src/exponential.js "Source") 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. # random.source(source) Returns the same type of function for generating random numbers but where the given random number generator *source* is used as the source of randomness instead of Math.random. The given random number generator must implement the same interface as Math.random and only return values in the range [0, 1). This is useful when a seeded random number generator is preferable to Math.random. For example: ```js var d3 = require("d3-random"), seedrandom = require("seedrandom"), random = d3.randomNormal.source(seedrandom("a22ebc7c488a3a47"))(0, 1); random(); // 0.9744193494813501 ``` d3-random-1.1.0/d3-random.sublime-project000066400000000000000000000002711310241076700201100ustar00rootroot00000000000000{ "folders": [ { "path": ".", "file_exclude_patterns": [ "*.sublime-workspace" ], "folder_exclude_patterns": [ "build" ] } ] } d3-random-1.1.0/index.js000066400000000000000000000005321310241076700147430ustar00rootroot00000000000000export {default as randomUniform} from "./src/uniform"; export {default as randomNormal} from "./src/normal"; export {default as randomLogNormal} from "./src/logNormal"; export {default as randomBates} from "./src/bates"; export {default as randomIrwinHall} from "./src/irwinHall"; export {default as randomExponential} from "./src/exponential"; d3-random-1.1.0/package.json000066400000000000000000000026471310241076700155750ustar00rootroot00000000000000{ "name": "d3-random", "version": "1.1.0", "description": "Generate random numbers from various distributions.", "keywords": [ "d3", "d3-module", "random", "rng" ], "homepage": "https://d3js.org/d3-random/", "license": "BSD-3-Clause", "author": { "name": "Mike Bostock", "url": "http://bost.ocks.org/mike" }, "main": "build/d3-random.js", "module": "index", "jsnext:main": "index", "repository": { "type": "git", "url": "https://github.com/d3/d3-random.git" }, "scripts": { "pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n d3 -o build/d3-random.js -- index.js", "test": "tape 'test/**/*-test.js' && eslint index.js src", "prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-random.js -c -m -o build/d3-random.min.js", "postpublish": "git push && git push --tags && cd ../d3.github.com && cp ../d3-random/build/d3-random.js d3-random.v1.js && cp ../d3-random/build/d3-random.min.js d3-random.v1.min.js && git add d3-random.v1.js d3-random.v1.min.js && git commit -m \"d3-random ${npm_package_version}\" && git push && cd - && zip -j build/d3-random.zip -- LICENSE README.md build/d3-random.js build/d3-random.min.js" }, "devDependencies": { "d3-array": "1", "eslint": "3", "package-preamble": "0.1", "rollup": "0.41", "seedrandom": "2", "tape": "4", "uglify-js": "^2.8.11" } } d3-random-1.1.0/src/000077500000000000000000000000001310241076700140655ustar00rootroot00000000000000d3-random-1.1.0/src/bates.js000066400000000000000000000005671310241076700155310ustar00rootroot00000000000000import defaultSource from "./defaultSource"; import irwinHall from "./irwinHall"; export default (function sourceRandomBates(source) { function randomBates(n) { var randomIrwinHall = irwinHall.source(source)(n); return function() { return randomIrwinHall() / n; }; } randomBates.source = sourceRandomBates; return randomBates; })(defaultSource); d3-random-1.1.0/src/defaultSource.js000066400000000000000000000000661310241076700172320ustar00rootroot00000000000000export default function() { return Math.random(); } d3-random-1.1.0/src/exponential.js000066400000000000000000000005111310241076700167460ustar00rootroot00000000000000import defaultSource from "./defaultSource"; export default (function sourceRandomExponential(source) { function randomExponential(lambda) { return function() { return -Math.log(1 - source()) / lambda; }; } randomExponential.source = sourceRandomExponential; return randomExponential; })(defaultSource); d3-random-1.1.0/src/irwinHall.js000066400000000000000000000005311310241076700163530ustar00rootroot00000000000000import defaultSource from "./defaultSource"; export default (function sourceRandomIrwinHall(source) { function randomIrwinHall(n) { return function() { for (var sum = 0, i = 0; i < n; ++i) sum += source(); return sum; }; } randomIrwinHall.source = sourceRandomIrwinHall; return randomIrwinHall; })(defaultSource); d3-random-1.1.0/src/logNormal.js000066400000000000000000000006251310241076700163600ustar00rootroot00000000000000import defaultSource from "./defaultSource"; import normal from "./normal"; export default (function sourceRandomLogNormal(source) { function randomLogNormal() { var randomNormal = normal.source(source).apply(this, arguments); return function() { return Math.exp(randomNormal()); }; } randomLogNormal.source = sourceRandomLogNormal; return randomLogNormal; })(defaultSource); d3-random-1.1.0/src/normal.js000066400000000000000000000013111310241076700157070ustar00rootroot00000000000000import defaultSource from "./defaultSource"; export default (function sourceRandomNormal(source) { function randomNormal(mu, sigma) { var x, r; mu = mu == null ? 0 : +mu; sigma = sigma == null ? 1 : +sigma; return function() { var y; // If available, use the second previously-generated uniform random. if (x != null) y = x, x = null; // Otherwise, generate a new x and y. else do { x = source() * 2 - 1; y = source() * 2 - 1; r = x * x + y * y; } while (!r || r > 1); return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r); }; } randomNormal.source = sourceRandomNormal; return randomNormal; })(defaultSource); d3-random-1.1.0/src/uniform.js000066400000000000000000000006701310241076700161050ustar00rootroot00000000000000import defaultSource from "./defaultSource"; export default (function sourceRandomUniform(source) { function randomUniform(min, max) { min = min == null ? 0 : +min; max = max == null ? 1 : +max; if (arguments.length === 1) max = min, min = 0; else max -= min; return function() { return source() * max + min; }; } randomUniform.source = sourceRandomUniform; return randomUniform; })(defaultSource); d3-random-1.1.0/test/000077500000000000000000000000001310241076700142555ustar00rootroot00000000000000d3-random-1.1.0/test/bates-test.js000066400000000000000000000031131310241076700166640ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")), skewness = require("./skewness"), kurtosis = require("./kurtosis"); require("./inDelta"); tape.test("d3.randomBates(n) returns random numbers with a mean of one-half", function(test) { var randomBates = d3.randomBates.source(seedrandom("f330fbece4c1c99f")); test.inDelta(d3.mean(d3.range(10000).map(randomBates(1))), 0.5, 0.05); test.inDelta(d3.mean(d3.range(10000).map(randomBates(10))), 0.5, 0.05); test.end(); }); tape.test("d3.randomBates(n) returns random numbers with a variance of 1 / (12 * n)", function(test) { var randomBates = d3.randomBates.source(seedrandom("c4af5ee918417093")); test.inDelta(d3.variance(d3.range(10000).map(randomBates(1))), 1 / 12, 0.05); test.inDelta(d3.variance(d3.range(10000).map(randomBates(10))), 1 / 120, 0.05); test.end(); }); tape.test("d3.randomBates(n) returns random numbers with a skewness of 0", function(test) { var randomBates = d3.randomBates.source(seedrandom("bb0bb470f346ff65")); test.inDelta(skewness(d3.range(10000).map(randomBates(1))), 0, 0.05); test.inDelta(skewness(d3.range(10000).map(randomBates(10))), 0, 0.05); test.end(); }); tape.test("d3.randomBates(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) { var randomBates = d3.randomBates.source(seedrandom("3c21f0c8f5a8332c")); test.inDelta(kurtosis(d3.range(10000).map(randomBates(1))), -6 / 5, 0.05); test.inDelta(kurtosis(d3.range(10000).map(randomBates(10))), -6 / 50, 0.05); test.end(); }); d3-random-1.1.0/test/exponential-test.js000066400000000000000000000016061310241076700201210ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")); require("./inDelta"); tape.test("d3.randomExponential(lambda) returns random exponentially distributed numbers with a mean of 1/lambda.", function(test) { var randomExponential = d3.randomExponential.source(seedrandom("d5cb594f444fc692")); var mean = 20, lambda = 1 / mean, // average rate (e.g. 1 per 20 minutes) times = d3.range(10000).map(randomExponential(lambda)); test.inDelta(d3.mean(times), mean, mean * 0.05); // Test cumulative distribution in intervals of 10. d3.range(10, 100, 10).forEach(function(elapsed) { var within = times.filter(function(t) { return t <= elapsed; }), expected = 1 - Math.exp(-elapsed * lambda); test.inDelta(within.length / times.length, expected, expected * 0.02); }); test.end(); }); d3-random-1.1.0/test/inDelta.js000066400000000000000000000004661310241076700162010ustar00rootroot00000000000000var tape = require("tape"); tape.Test.prototype.inDelta = function(actual, expected, delta) { this._assert(expected - delta <= actual && actual <= expected + delta, { message: "should be in delta", operator: "inDelta", actual: actual, expected: [expected - delta, expected + delta] }); }; d3-random-1.1.0/test/irwinHall-test.js000066400000000000000000000032271310241076700175250ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")), skewness = require("./skewness"), kurtosis = require("./kurtosis"); require("./inDelta"); tape.test("d3.randomIrwinHall(n) returns random numbers with a mean of n / 2", function(test) { var randomIrwinHall = d3.randomIrwinHall.source(seedrandom("f330fbece4c1c99f")); test.inDelta(d3.mean(d3.range(10000).map(randomIrwinHall(1))), 1 / 2, 0.05); test.inDelta(d3.mean(d3.range(10000).map(randomIrwinHall(10))), 10 / 2, 0.05); test.end(); }); tape.test("d3.randomIrwinHall(n) returns random numbers with a variance of n / 12", function(test) { var randomIrwinHall = d3.randomIrwinHall.source(seedrandom("c4af5ee918417093")); test.inDelta(d3.variance(d3.range(10000).map(randomIrwinHall(1))), 1 / 12, 0.05); test.inDelta(d3.variance(d3.range(10000).map(randomIrwinHall(10))), 10 / 12, 0.05); test.end(); }); tape.test("d3.randomIrwinHall(n) returns random numbers with a skewness of 0", function(test) { var randomIrwinHall = d3.randomIrwinHall.source(seedrandom("bb0bb470f346ff65")); test.inDelta(skewness(d3.range(10000).map(randomIrwinHall(1))), 0, 0.05); test.inDelta(skewness(d3.range(10000).map(randomIrwinHall(10))), 0, 0.05); test.end(); }); tape.test("d3.randomIrwinHall(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) { var randomIrwinHall = d3.randomIrwinHall.source(seedrandom("3c21f0c8f5a8332c")); test.inDelta(kurtosis(d3.range(10000).map(randomIrwinHall(1))), -6 / 5, 0.05); test.inDelta(kurtosis(d3.range(10000).map(randomIrwinHall(10))), -6 / 50, 0.05); test.end(); }); d3-random-1.1.0/test/kurtosis.js000066400000000000000000000005251310241076700165000ustar00rootroot00000000000000var d3 = require("d3-array"); module.exports = function(numbers) { var mean = d3.mean(numbers), sum4 = 0, sum2 = 0, v, i = -1, n = numbers.length; while (++i < n) { v = numbers[i] - mean; sum2 += v * v; sum4 += v * v * v * v; } return (1 / n) * sum4 / Math.pow((1 / n) * sum2, 2) - 3; }; d3-random-1.1.0/test/logNormal-test.js000066400000000000000000000041151310241076700175230ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")); require("./inDelta"); tape.test("d3.randomLogNormal() returns random numbers with a log-mean of zero", function(test) { var randomLogNormal = d3.randomLogNormal.source(seedrandom("a22ebc7c488a3a47")); test.inDelta(d3.mean(d3.range(10000).map(randomLogNormal()), Math.log), 0, 0.05); test.end(); }); tape.test("d3.randomLogNormal() returns random numbers with a log-standard deviation of one", function(test) { var randomLogNormal = d3.randomLogNormal.source(seedrandom("06fd26b46c25607e")); test.inDelta(d3.deviation(d3.range(10000).map(randomLogNormal()), Math.log), 1, 0.05); test.end(); }); tape.test("d3.randomLogNormal(mu) returns random numbers with the specified log-mean", function(test) { var randomLogNormal = d3.randomLogNormal.source(seedrandom("fffe77600db5c1ad")); test.inDelta(d3.mean(d3.range(10000).map(randomLogNormal(42)), Math.log), 42, 0.05); test.inDelta(d3.mean(d3.range(10000).map(randomLogNormal(-2)), Math.log), -2, 0.05); test.end(); }); tape.test("d3.randomLogNormal(mu) returns random numbers with a log-standard deviation of 1", function(test) { var randomLogNormal = d3.randomLogNormal.source(seedrandom("9caf2156de45315a")); test.inDelta(d3.deviation(d3.range(10000).map(randomLogNormal(42)), Math.log), 1, 0.05); test.inDelta(d3.deviation(d3.range(10000).map(randomLogNormal(-2)), Math.log), 1, 0.05); test.end(); }); tape.test("d3.randomLogNormal(mu, sigma) returns random numbers with the specified log-mean and log-standard deviation", function(test) { var randomLogNormal = d3.randomLogNormal.source(seedrandom("c0d761f591fb5e43")); test.inDelta(d3.mean(d3.range(10000).map(randomLogNormal(42, 2)), Math.log), 42, 0.05); test.inDelta(d3.mean(d3.range(10000).map(randomLogNormal(-2, 2)), Math.log), -2, 0.05); test.inDelta(d3.deviation(d3.range(10000).map(randomLogNormal(42, 2)), Math.log), 2, 0.05); test.inDelta(d3.deviation(d3.range(10000).map(randomLogNormal(-2, 2)), Math.log), 2, 0.05); test.end(); }); d3-random-1.1.0/test/normal-test.js000066400000000000000000000035551310241076700170700ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")); require("./inDelta"); tape.test("randomNormal() returns random numbers with a mean of zero", function(test) { var randomNormal = d3.randomNormal.source(seedrandom("a22ebc7c488a3a47")); test.inDelta(d3.mean(d3.range(10000).map(randomNormal())), 0, .05); test.end(); }); tape.test("randomNormal() returns random numbers with a standard deviation of one", function(test) { var randomNormal = d3.randomNormal.source(seedrandom("06fd26b46c25607e")); test.inDelta(d3.deviation(d3.range(10000).map(randomNormal())), 1, .05); test.end(); }); tape.test("randomNormal(mu) returns random numbers with the specified mean", function(test) { var randomNormal = d3.randomNormal.source(seedrandom("fffe77600db5c1ad")); test.inDelta(d3.mean(d3.range(10000).map(randomNormal(42))), 42, .05); test.inDelta(d3.mean(d3.range(10000).map(randomNormal(-2))), -2, .05); test.end(); }); tape.test("randomNormal(mu) returns random numbers with a standard deviation of 1", function(test) { var randomNormal = d3.randomNormal.source(seedrandom("9caf2156de45315a")); test.inDelta(d3.deviation(d3.range(10000).map(randomNormal(42))), 1, .05); test.inDelta(d3.deviation(d3.range(10000).map(randomNormal(-2))), 1, .05); test.end(); }); tape.test("randomNormal(mu, sigma) returns random numbers with the specified mean and standard deviation", function(test) { var randomNormal = d3.randomNormal.source(seedrandom("c0d761f591fb5e43")); test.inDelta(d3.mean(d3.range(10000).map(randomNormal(42, 2))), 42, .05); test.inDelta(d3.mean(d3.range(10000).map(randomNormal(-2, 2))), -2, .05); test.inDelta(d3.deviation(d3.range(10000).map(randomNormal(42, 2))), 2, .05); test.inDelta(d3.deviation(d3.range(10000).map(randomNormal(-2, 2))), 2, .05); test.end(); }); d3-random-1.1.0/test/skewness.js000066400000000000000000000005271310241076700164610ustar00rootroot00000000000000var d3 = require("d3-array"); module.exports = function(numbers) { var mean = d3.mean(numbers), sum3 = 0, sum2 = 0, v, i = -1, n = numbers.length; while (++i < n) { v = numbers[i] - mean; sum2 += v * v; sum3 += v * v * v; } return (1 / n) * sum3 / Math.pow((1 / (n - 1)) * sum2, 3 / 2); }; d3-random-1.1.0/test/uniform-test.js000066400000000000000000000036231310241076700172530ustar00rootroot00000000000000var tape = require("tape"), seedrandom = require("seedrandom"), d3 = Object.assign({}, require("../"), require("d3-array")); require("./inDelta"); tape.test("randomUniform() returns random numbers with a mean of 0.5", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("d7bcbccaa96bba8c")); test.inDelta(d3.mean(d3.range(10000).map(randomUniform())), 0.5, .05); test.end(); }); tape.test("randomUniform() returns random numbers within the range [0,1)", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("f232de9b208a7137")); test.ok(d3.min(d3.range(10000).map(randomUniform())) >= 0); test.ok(d3.min(d3.range(10000).map(randomUniform())) < 1); test.end(); }); tape.test("randomUniform(max) returns random numbers with a mean of max / 2", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("c52f4e6cd112aada")); test.inDelta(d3.mean(d3.range(10000).map(randomUniform(42))), 21, .5); test.end(); }); tape.test("randomUniform(max) returns random numbers within the range [0,max)", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("8f2959eba39debfd")); test.ok(d3.min(d3.range(10000).map(randomUniform(42))) >= 0); test.ok(d3.min(d3.range(10000).map(randomUniform(42))) < 42); test.end(); }); tape.test("randomUniform(min, max) returns random numbers with a mean of (min + max) / 2", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("5ea383210c9bdd21")); test.inDelta(d3.mean(d3.range(10000).map(randomUniform(10, 42))), 26, .5); test.end(); }); tape.test("randomUniform(min, max) returns random numbers within the range [min,max)", function(test) { var randomUniform = d3.randomUniform.source(seedrandom("88f461e6b7454981")); test.ok(d3.min(d3.range(10000).map(randomUniform(10, 42))) >= 10); test.ok(d3.min(d3.range(10000).map(randomUniform(10, 42))) < 42); test.end(); });