Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的问题本质上是:
double d = random.nextDouble() * 2 (generates a number from 0 to 1 and multiplies by 2)
相当于:
random.nextDouble(2) (generates a number from 0 to 2)
我只是想知道它的理论。将随机生成的数字相乘是否会以任何方式影响其均匀分布?
绝对可以。
如果您没有注意到,d将始终是 2 的倍数。而在第二种情况下,数字将均匀分布在 [0,2) 之间。
d
即使您将两个真正的随机变量相乘,概率分布也会发生变化。请参阅了解“随机性”