d3.randomUniform()

d3.randomUniform([min, ][max])

Returns a function for generating random numbers with a uniform distribution. 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:

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 to generate uniform distributions directly. For example, to generate a random integer between 0 and 99 (inclusive), you can say Math.random() * 100 | 0.

doc_D3_Js
2016-11-24 10:27:05
Comments
Leave a Comment

Please login to continue.