D3.js中的randomBates()函數返回用於生成隨機數的函數。返回的此函數基於Bates分布。
用法:
randomBates(n)
參數:該函數接受如上所述和以下描述的單個參數:
- n:它是與bates分發一起使用以生成隨機數的任何數字。
返回值:它返回函數。
下麵給出了上述函數的一些示例。
範例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"
src = "https://d3js.org/d3.v4.min.js">
</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>
輸出:
範例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"
src = "https://d3js.org/d3.v4.min.js">
</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>
輸出:
相關用法
- PHP each()用法及代碼示例
- d3.js now()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- d3.js d3.hsl()用法及代碼示例
- d3.js d3.map.has()用法及代碼示例
- d3.js d3.map.get()用法及代碼示例
- p5.js arc()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- p5.js nfp()用法及代碼示例
- PHP pi( )用法及代碼示例
- p5.js nfc()用法及代碼示例
- p5.js nf()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
- PHP pow( )用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js randomBates() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。