diff --git a/README.md b/README.md
index 6c1bc93..17409fc 100644
--- a/README.md
+++ b/README.md
@@ -14,33 +14,33 @@ In a vanilla environment, a `d3_random` global is exported. [Try d3-random in yo
## API Reference
-# d3_random.uniform([min, ][max])
+# d3.randomUniform([min, ][max])
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_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.
+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_random.normal([mu][, sigma])
+# d3.randomNormal([mu][, sigma])
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_random.logNormal([mu][, sigma])
+# d3.randomLogNormal([mu][, sigma])
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.
-# d3_random.bates(n)
+# d3.randomBates(n)
Returns a function for generating random numbers with a [Bates distribution](https://en.wikipedia.org/wiki/Bates_distribution) with *n* independent variables.
-# d3_random.irwinHall(n)
+# d3.randomIrwinHall(n)
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_random.exponential(lambda)
+# d3.randomExponential(lambda)
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.
diff --git a/index.js b/index.js
index 4b5cd9d..4141125 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
-export {default as uniform} from "./src/uniform";
-export {default as normal} from "./src/normal";
-export {default as logNormal} from "./src/logNormal";
-export {default as bates} from "./src/bates";
-export {default as irwinHall} from "./src/irwinHall";
-export {default as exponential} from "./src/exponential";
+export {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";
diff --git a/package.json b/package.json
index 31951d4..46aad3c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "d3-random",
- "version": "0.1.1",
+ "version": "0.2.0",
"description": "Generate random numbers from various distributions.",
"keywords": [
"d3",
@@ -25,7 +25,7 @@
"prepublish": "npm run test && uglifyjs build/d3-random.js -c -m -o build/d3-random.min.js && rm -f build/d3-random.zip && zip -j build/d3-random.zip -- LICENSE README.md build/d3-random.js build/d3-random.min.js"
},
"devDependencies": {
- "d3-array": "~0.6.1",
+ "d3-array": "~0.7.0",
"faucet": "0.0",
"rollup": "0.20.5",
"seedrandom": "2",
diff --git a/test/bates-test.js b/test/bates-test.js
index 575cc7b..46b9447 100644
--- a/test/bates-test.js
+++ b/test/bates-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../"),
skewness = require("./skewness"),
kurtosis = require("./kurtosis");
@@ -9,35 +9,35 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("bates(n) returns random numbers with a mean of one-half", function(test) {
+tape.test("randomBates(n) returns random numbers with a mean of one-half", function(test) {
Math.seedrandom("f330fbece4c1c99f");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.bates(1))), .5, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.bates(10))), .5, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomBates(1))), .5, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomBates(10))), .5, .05);
test.end();
});
-tape.test("bates(n) returns random numbers with a variance of 1 / (12 * n)", function(test) {
+tape.test("randomBates(n) returns random numbers with a variance of 1 / (12 * n)", function(test) {
Math.seedrandom("c4af5ee918417093");
- test.inDelta(arrays.variance(arrays.range(10000).map(random.bates(1))), 1 / 12, .05);
- test.inDelta(arrays.variance(arrays.range(10000).map(random.bates(10))), 1 / 120, .05);
+ test.inDelta(array.variance(array.range(10000).map(random.randomBates(1))), 1 / 12, .05);
+ test.inDelta(array.variance(array.range(10000).map(random.randomBates(10))), 1 / 120, .05);
test.end();
});
-tape.test("bates(n) returns random numbers with a skewness of 0", function(test) {
+tape.test("randomBates(n) returns random numbers with a skewness of 0", function(test) {
Math.seedrandom("bb0bb470f346ff65");
- test.inDelta(skewness(arrays.range(10000).map(random.bates(1))), 0, .05);
- test.inDelta(skewness(arrays.range(10000).map(random.bates(10))), 0, .05);
+ test.inDelta(skewness(array.range(10000).map(random.randomBates(1))), 0, .05);
+ test.inDelta(skewness(array.range(10000).map(random.randomBates(10))), 0, .05);
test.end();
});
-tape.test("bates(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) {
+tape.test("randomBates(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) {
Math.seedrandom("3c21f0c8f5a8332c");
- test.inDelta(kurtosis(arrays.range(10000).map(random.bates(1))), -6 / 5, .05);
- test.inDelta(kurtosis(arrays.range(10000).map(random.bates(10))), -6 / 50, .05);
+ test.inDelta(kurtosis(array.range(10000).map(random.randomBates(1))), -6 / 5, .05);
+ test.inDelta(kurtosis(array.range(10000).map(random.randomBates(10))), -6 / 50, .05);
test.end();
});
-tape("bates() [teardown]", function(test) {
+tape("randomBates() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});
diff --git a/test/exponential-test.js b/test/exponential-test.js
index 9069636..2386ea8 100644
--- a/test/exponential-test.js
+++ b/test/exponential-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../");
require("seedrandom");
@@ -7,17 +7,17 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("exponential(lambda) returns random exponentially distributed numbers with a mean of 1/lambda.", function(test) {
+tape.test("randomExponential(lambda) returns random exponentially distributed numbers with a mean of 1/lambda.", function(test) {
Math.seedrandom("d5cb594f444fc692");
var mean = 20,
lambda = 1 / mean, // average rate (e.g. 1 per 20 minutes)
- times = arrays.range(10000).map(random.exponential(lambda));
+ times = array.range(10000).map(random.randomExponential(lambda));
- test.inDelta(arrays.mean(times), mean, mean * 0.05);
+ test.inDelta(array.mean(times), mean, mean * 0.05);
// Test cumulative distribution in intervals of 10.
- arrays.range(10, 100, 10).forEach(function(elapsed) {
+ array.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);
@@ -26,7 +26,7 @@ tape.test("exponential(lambda) returns random exponentially distributed numbers
test.end();
});
-tape("exponential() [teardown]", function(test) {
+tape("randomExponential() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});
diff --git a/test/irwinHall-test.js b/test/irwinHall-test.js
index 22e1fee..ebae414 100644
--- a/test/irwinHall-test.js
+++ b/test/irwinHall-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../"),
skewness = require("./skewness"),
kurtosis = require("./kurtosis");
@@ -9,35 +9,35 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("irwinHall(n) returns random numbers with a mean of n / 2", function(test) {
+tape.test("randomIrwinHall(n) returns random numbers with a mean of n / 2", function(test) {
Math.seedrandom("f330fbece4c1c99f");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.irwinHall(1))), 1 / 2, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.irwinHall(10))), 10 / 2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomIrwinHall(1))), 1 / 2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomIrwinHall(10))), 10 / 2, .05);
test.end();
});
-tape.test("irwinHall(n) returns random numbers with a variance of n / 12", function(test) {
+tape.test("randomIrwinHall(n) returns random numbers with a variance of n / 12", function(test) {
Math.seedrandom("c4af5ee918417093");
- test.inDelta(arrays.variance(arrays.range(10000).map(random.irwinHall(1))), 1 / 12, .05);
- test.inDelta(arrays.variance(arrays.range(10000).map(random.irwinHall(10))), 10 / 12, .05);
+ test.inDelta(array.variance(array.range(10000).map(random.randomIrwinHall(1))), 1 / 12, .05);
+ test.inDelta(array.variance(array.range(10000).map(random.randomIrwinHall(10))), 10 / 12, .05);
test.end();
});
-tape.test("irwinHall(n) returns random numbers with a skewness of 0", function(test) {
+tape.test("randomIrwinHall(n) returns random numbers with a skewness of 0", function(test) {
Math.seedrandom("bb0bb470f346ff65");
- test.inDelta(skewness(arrays.range(10000).map(random.irwinHall(1))), 0, .05);
- test.inDelta(skewness(arrays.range(10000).map(random.irwinHall(10))), 0, .05);
+ test.inDelta(skewness(array.range(10000).map(random.randomIrwinHall(1))), 0, .05);
+ test.inDelta(skewness(array.range(10000).map(random.randomIrwinHall(10))), 0, .05);
test.end();
});
-tape.test("irwinHall(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) {
+tape.test("randomIrwinHall(n) returns random numbers with a kurtosis of -6 / (5 * n)", function(test) {
Math.seedrandom("3c21f0c8f5a8332c");
- test.inDelta(kurtosis(arrays.range(10000).map(random.irwinHall(1))), -6 / 5, .05);
- test.inDelta(kurtosis(arrays.range(10000).map(random.irwinHall(10))), -6 / 50, .05);
+ test.inDelta(kurtosis(array.range(10000).map(random.randomIrwinHall(1))), -6 / 5, .05);
+ test.inDelta(kurtosis(array.range(10000).map(random.randomIrwinHall(10))), -6 / 50, .05);
test.end();
});
-tape("irwinHall() [teardown]", function(test) {
+tape("randomIrwinHall() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});
diff --git a/test/kurtosis.js b/test/kurtosis.js
index 7a477f0..ec69f40 100644
--- a/test/kurtosis.js
+++ b/test/kurtosis.js
@@ -1,15 +1,15 @@
-var arrays = require("d3-arrays");
+var array = require("d3-array");
-module.exports = function(array) {
- var mean = arrays.mean(array),
+module.exports = function(numbers) {
+ var mean = array.mean(numbers),
sum4 = 0,
sum2 = 0,
v,
i = -1,
- n = array.length;
+ n = numbers.length;
while (++i < n) {
- v = array[i] - mean;
+ v = numbers[i] - mean;
sum2 += v * v;
sum4 += v * v * v * v;
}
diff --git a/test/logNormal-test.js b/test/logNormal-test.js
index 61c7a05..73b6ace 100644
--- a/test/logNormal-test.js
+++ b/test/logNormal-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../");
require("seedrandom");
@@ -7,42 +7,42 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("logNormal() returns random numbers with a log-mean of zero", function(test) {
+tape.test("randomLogNormal() returns random numbers with a log-mean of zero", function(test) {
Math.seedrandom("a22ebc7c488a3a47");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.logNormal()), Math.log), 0, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomLogNormal()), Math.log), 0, .05);
test.end();
});
-tape.test("logNormal() returns random numbers with a log-standard deviation of one", function(test) {
+tape.test("randomLogNormal() returns random numbers with a log-standard deviation of one", function(test) {
Math.seedrandom("06fd26b46c25607e");
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.logNormal()), Math.log), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomLogNormal()), Math.log), 1, .05);
test.end();
});
-tape.test("logNormal(mu) returns random numbers with the specified log-mean", function(test) {
+tape.test("randomLogNormal(mu) returns random numbers with the specified log-mean", function(test) {
Math.seedrandom("fffe77600db5c1ad");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.logNormal(42)), Math.log), 42, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.logNormal(-2)), Math.log), -2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomLogNormal(42)), Math.log), 42, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomLogNormal(-2)), Math.log), -2, .05);
test.end();
});
-tape.test("logNormal(mu) returns random numbers with a log-standard deviation of 1", function(test) {
+tape.test("randomLogNormal(mu) returns random numbers with a log-standard deviation of 1", function(test) {
Math.seedrandom("9caf2156de45315a");
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.logNormal(42)), Math.log), 1, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.logNormal(-2)), Math.log), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomLogNormal(42)), Math.log), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomLogNormal(-2)), Math.log), 1, .05);
test.end();
});
-tape.test("logNormal(mu, sigma) returns random numbers with the specified log-mean and log-standard deviation", function(test) {
+tape.test("randomLogNormal(mu, sigma) returns random numbers with the specified log-mean and log-standard deviation", function(test) {
Math.seedrandom("c0d761f591fb5e43");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.logNormal(42, 2)), Math.log), 42, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.logNormal(-2, 2)), Math.log), -2, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.logNormal(42, 2)), Math.log), 2, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.logNormal(-2, 2)), Math.log), 2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomLogNormal(42, 2)), Math.log), 42, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomLogNormal(-2, 2)), Math.log), -2, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomLogNormal(42, 2)), Math.log), 2, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomLogNormal(-2, 2)), Math.log), 2, .05);
test.end();
});
-tape("logNormal() [teardown]", function(test) {
+tape("randomLogNormal() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});
diff --git a/test/normal-test.js b/test/normal-test.js
index 4810cac..409be2d 100644
--- a/test/normal-test.js
+++ b/test/normal-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../");
require("seedrandom");
@@ -7,42 +7,42 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("normal() returns random numbers with a mean of zero", function(test) {
+tape.test("randomNormal() returns random numbers with a mean of zero", function(test) {
Math.seedrandom("a22ebc7c488a3a47");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.normal())), 0, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomNormal())), 0, .05);
test.end();
});
-tape.test("normal() returns random numbers with a standard deviation of one", function(test) {
+tape.test("randomNormal() returns random numbers with a standard deviation of one", function(test) {
Math.seedrandom("06fd26b46c25607e");
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.normal())), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomNormal())), 1, .05);
test.end();
});
-tape.test("normal(mu) returns random numbers with the specified mean", function(test) {
+tape.test("randomNormal(mu) returns random numbers with the specified mean", function(test) {
Math.seedrandom("fffe77600db5c1ad");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.normal(42))), 42, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.normal(-2))), -2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomNormal(42))), 42, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomNormal(-2))), -2, .05);
test.end();
});
-tape.test("normal(mu) returns random numbers with a standard deviation of 1", function(test) {
+tape.test("randomNormal(mu) returns random numbers with a standard deviation of 1", function(test) {
Math.seedrandom("9caf2156de45315a");
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.normal(42))), 1, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.normal(-2))), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomNormal(42))), 1, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomNormal(-2))), 1, .05);
test.end();
});
-tape.test("normal(mu, sigma) returns random numbers with the specified mean and standard deviation", function(test) {
+tape.test("randomNormal(mu, sigma) returns random numbers with the specified mean and standard deviation", function(test) {
Math.seedrandom("c0d761f591fb5e43");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.normal(42, 2))), 42, .05);
- test.inDelta(arrays.mean(arrays.range(10000).map(random.normal(-2, 2))), -2, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.normal(42, 2))), 2, .05);
- test.inDelta(arrays.deviation(arrays.range(10000).map(random.normal(-2, 2))), 2, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomNormal(42, 2))), 42, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomNormal(-2, 2))), -2, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomNormal(42, 2))), 2, .05);
+ test.inDelta(array.deviation(array.range(10000).map(random.randomNormal(-2, 2))), 2, .05);
test.end();
});
-tape("normal() [teardown]", function(test) {
+tape("randomNormal() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});
diff --git a/test/skewness.js b/test/skewness.js
index 2cd6759..28c1f94 100644
--- a/test/skewness.js
+++ b/test/skewness.js
@@ -1,15 +1,15 @@
-var arrays = require("d3-arrays");
+var array = require("d3-array");
-module.exports = function(array) {
- var mean = arrays.mean(array),
+module.exports = function(numbers) {
+ var mean = array.mean(numbers),
sum3 = 0,
sum2 = 0,
v,
i = -1,
- n = array.length;
+ n = numbers.length;
while (++i < n) {
- v = array[i] - mean;
+ v = numbers[i] - mean;
sum2 += v * v;
sum3 += v * v * v;
}
diff --git a/test/uniform-test.js b/test/uniform-test.js
index 0bfd8b2..ac97880 100644
--- a/test/uniform-test.js
+++ b/test/uniform-test.js
@@ -1,5 +1,5 @@
var tape = require("tape"),
- arrays = require("d3-arrays"),
+ array = require("d3-array"),
random = require("../");
require("seedrandom");
@@ -7,46 +7,46 @@ require("./inDelta");
var mathRandom = Math.random;
-tape.test("uniform() returns random numbers with a mean of 0.5", function(test) {
+tape.test("randomUniform() returns random numbers with a mean of 0.5", function(test) {
Math.seedrandom("d7bcbccaa96bba8c");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.uniform())), 0.5, .05);
+ test.inDelta(array.mean(array.range(10000).map(random.randomUniform())), 0.5, .05);
test.end();
});
-tape.test("uniform() returns random numbers within the range [0,1)", function(test) {
+tape.test("randomUniform() returns random numbers within the range [0,1)", function(test) {
Math.seedrandom("f232de9b208a7137");
- test.ok(arrays.min(arrays.range(10000).map(random.uniform())) >= 0);
- test.ok(arrays.min(arrays.range(10000).map(random.uniform())) < 1);
+ test.ok(array.min(array.range(10000).map(random.randomUniform())) >= 0);
+ test.ok(array.min(array.range(10000).map(random.randomUniform())) < 1);
test.end();
});
-tape.test("uniform(max) returns random numbers with a mean of max / 2", function(test) {
+tape.test("randomUniform(max) returns random numbers with a mean of max / 2", function(test) {
Math.seedrandom("c52f4e6cd112aada");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.uniform(42))), 21, .5);
+ test.inDelta(array.mean(array.range(10000).map(random.randomUniform(42))), 21, .5);
test.end();
});
-tape.test("uniform(max) returns random numbers within the range [0,max)", function(test) {
+tape.test("randomUniform(max) returns random numbers within the range [0,max)", function(test) {
Math.seedrandom("8f2959eba39debfd");
- test.ok(arrays.min(arrays.range(10000).map(random.uniform(42))) >= 0);
- test.ok(arrays.min(arrays.range(10000).map(random.uniform(42))) < 42);
+ test.ok(array.min(array.range(10000).map(random.randomUniform(42))) >= 0);
+ test.ok(array.min(array.range(10000).map(random.randomUniform(42))) < 42);
test.end();
});
-tape.test("uniform(min, max) returns random numbers with a mean of (min + max) / 2", function(test) {
+tape.test("randomUniform(min, max) returns random numbers with a mean of (min + max) / 2", function(test) {
Math.seedrandom("5ea383210c9bdd21");
- test.inDelta(arrays.mean(arrays.range(10000).map(random.uniform(10, 42))), 26, .5);
+ test.inDelta(array.mean(array.range(10000).map(random.randomUniform(10, 42))), 26, .5);
test.end();
});
-tape.test("uniform(min, max) returns random numbers within the range [min,max)", function(test) {
+tape.test("randomUniform(min, max) returns random numbers within the range [min,max)", function(test) {
Math.seedrandom("88f461e6b7454981");
- test.ok(arrays.min(arrays.range(10000).map(random.uniform(10, 42))) >= 10);
- test.ok(arrays.min(arrays.range(10000).map(random.uniform(10, 42))) < 42);
+ test.ok(array.min(array.range(10000).map(random.randomUniform(10, 42))) >= 10);
+ test.ok(array.min(array.range(10000).map(random.randomUniform(10, 42))) < 42);
test.end();
});
-tape("uniform() [teardown]", function(test) {
+tape("randomUniform() [teardown]", function(test) {
Math.random = mathRandom;
test.end();
});