randomExponential()函數用於返回根據 index 分布生成隨機數的函數。
用法:
d3.randomExponential(lambda);
參數:它僅采用上麵給出和下麵描述的一個參數。
- lambda: index 分布函數的比率等於泊鬆過程中事件之間的時間。
返回值:它返回一個函數。
注意:每次運行該函數時,輸出值可能都不同。
下麵給出了上述函數的一些示例。
範例1:當λ大於1時。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Document</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>
/* The value of the output may be
different each time the function is run.*/
console.log(d3.randomExponential(5)())
console.log(d3.randomExponential(5)())
console.log(d3.randomExponential(5)())
console.log(d3.randomExponential(5)())
console.log(d3.randomExponential(5)())
</script>
</body>
</html>
輸出:
範例2:當lambda的值小於一時。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Document</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>
/* The value of the output may be
different each time the function is run.*/
console.log(d3.randomExponential(0.5)())
/* Smaller the lamba greater the random value generated.
console.log(d3.randomExponential(0.05)())
console.log(d3.randomExponential(0.005)())
console.log(d3.randomExponential(0.0005)())
</script>
</body>
</html>
輸出:
相關用法
- d3.js d3.map.set()用法及代碼示例
- p5.js box()用法及代碼示例
- CSS var()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- p5.js nf()用法及代碼示例
- p5.js nfc()用法及代碼示例
- p5.js nfp()用法及代碼示例
- PHP min( )用法及代碼示例
- PHP each()用法及代碼示例
- PHP key()用法及代碼示例
- PHP pos()用法及代碼示例
- PHP end()用法及代碼示例
- d3.js d3.hsl()用法及代碼示例
- PHP next()用法及代碼示例
- PHP pow( )用法及代碼示例
注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js randomExponential() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。