D3.js randomIrwinHall() Function
The d3.randomIrwinHall() function in d3.js is used to generate the random number based on the Irwinhall distribution having “n” independent variables.
Syntax:
d3.randomIrwinHall(n)
Parameters: It takes only one parameter as given above and described below.
- n: It is the number of independent variables given to the Irwin hall distribution function.
Returns: It returns a function.
Example 1: When n is greater than zero.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content=
" width = device -width,
initial-scale = 1 .0">
</ head >
< body >
< div class = "b1" ></ div >
< div class = "b2" ></ div >
< script type = "text/javascript"
</ script >
< script >
// Every output is different and
// generating the itwinhall random
// numbers
console.log(d3.randomIrwinHall(4)())
console.log(d3.randomIrwinHall(4)())
console.log(d3.randomIrwinHall(4)())
console.log(d3.randomIrwinHall(4)())
console.log(d3.randomIrwinHall(4)())
</ script >
</ body >
</ html >
|
Output:
Example 2: When n is less than zero.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content =
"width=device-width,initial-scale=1.0" >
</ head >
< body >
< div class = "b1" ></ div >
< div class = "b2" ></ div >
< script type = "text/javascript"
</ script >
< script >
// Any value less than zero gives
// static value of zero
console.log(d3.randomIrwinHall(-4)())
console.log(d3.randomIrwinHall(0.004)())
console.log(d3.randomIrwinHall(4)(4))
console.log(d3.randomIrwinHall(-0.008)())
</ script >
</ body >
</ html >
|
Output:
Last Updated :
07 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...