D3.js randomBates() Function

The randomBates() function in D3.js returns a function that is used for generating random numbers. This function that is returned is based on the Bates distribution.
Syntax:
randomBates(n)
Parameters: This function accepts a single parameter as mentioned above and described below:
- n: It is any number that is used with bates distribution to generate the random number.
Returns: It returns the function.
Below given are a few examples of the above function.
Example 1:
HTML
<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport"         content="width=device-width, initial-scale=1.0">   <title>D3.js randomBates() Function</title> </head> <style> </style> <body>   <!-- Fetching from CDN of D3.js -->  <script type = "text/javascript"   </script>   <script>     // Output may be different each time     // the function is run     console.log(d3.randomBates(0)());      console.log(d3.randomBates(1)());      console.log(d3.randomBates(2)());      console.log(d3.randomBates(3)());      console.log(d3.randomBates(4)());      console.log(d3.randomBates(5)());    </script> </body> </html> |
Output:
Example 2:
HTML
<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport"         content="width=device-width, initial-scale=1.0">   <title>D3.js randomBates() Function</title> </head> <style> </style> <body>   <!-- Fetching from CDN of D3.js -->  <script type = "text/javascript"   </script>   <script>     // Output may be different each time     // the function is run     console.log(d3.randomBates(-10)());      console.log(d3.randomBates(-1)(85));     // Please note n is between 1 and 0 then     // random number     // Generated is greater than 1     console.log(d3.randomBates(0.0052)());      console.log(d3.randomBates(.0085)());      console.log(d3.randomBates(0.005)());      console.log(d3.randomBates(1.025)());    </script> </body> </html> |
Output:
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!




