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 > Ā Ā Ā Ā Ā Ā <!--Fetching from CDN of D3.js --> Ā Ā Ā Ā < 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 > Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā <!--Fetching from CDN of D3.js --> Ā Ā Ā Ā < 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: