Java Random nextGaussian() 方法

2024年11月3日 | 阅读 2 分钟

Random 类的 nextGaussian() 方法从随机数生成器的序列中返回下一个伪随机的、高斯(正态)分布的双精度值,平均值为 0.0,标准差为 1.0。

语法

参数

不适用

返回值

nextDouble() 方法返回下一个伪随机的高斯分布双精度数,平均值为 0.0,标准差为 1.0。

示例 1

输出

Random Gaussian value : -3.3518483633913014
Random Gaussian value : -1.3767908077736486

示例 2

立即测试

输出

-0.7001112567605307 
-1.0015898772831247 
-0.8454172962601406 
0.12805541404557777 
-0.8336655342786383

示例 3

立即测试

输出

Enter the number of Visitors.4
Enter the name of 4 students.
1 Reema
2 Ravi
3 Rahul
4 Sonia
Sorry! Reema you are out of the game.
Congratulations! Ravi you are in the game.
Sorry! Rahul you are out of the game.
Sorry! Sonia you are out of the game.