From d4ff217f0c70b61225b46cb5ba01c92e51a2f068 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 3 May 2017 10:22:04 -0700 Subject: [PATCH] Add random.source example. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d07cf2..65b0c49 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,12 @@ Returns a function for generating random numbers with an [exponential distributi # 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. +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 +```