Skip to content

Commit

Permalink
Add random.source example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed May 3, 2017
1 parent 9c443e7 commit d4ff217
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ Returns a function for generating random numbers with an [exponential distributi

<a name="random_source" href="#random_source">#</a> <i>random</i>.<b>source</b>(<i>source</i>)

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
```

0 comments on commit d4ff217

Please sign in to comment.