了解“随机性"; [英] Understanding "randomness"

查看:90
本文介绍了了解“随机性";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法解决这个问题,这是比较随机的吗?

I can't get my head around this, which is more random?

rand()

OR :

rand() * rand()

我发现它是一个真正的脑筋急转弯,您能帮帮我吗?

I´m finding it a real brain teaser, could you help me out?

直觉上我知道数学答案将是它们是同样随机的,但是我忍不住想,如果您将两者相乘时两次运行随机数算法",则会创建出更多随机性而不是只做一次.

Intuitively I know that the mathematical answer will be that they are equally random, but I can't help but think that if you "run the random number algorithm" twice when you multiply the two together you'll create something more random than just doing it once.

推荐答案

请澄清

尽管当您尝试发现伪随机变量或其乘积的随机性时,前面的答案是正确的,但应注意,尽管 Random()通常是均匀分布的,但不是Random()* Random().

Just a clarification

Although the previous answers are right whenever you try to spot the randomness of a pseudo-random variable or its multiplication, you should be aware that while Random() is usually uniformly distributed, Random() * Random() is not.

这是通过伪随机变量模拟的均匀随机分布样本:

This is a uniform random distribution sample simulated through a pseudo-random variable:

        BarChart[BinCounts[RandomReal[{0, 1}, 50000], 0.01]]

这是将两个随机变量相乘后得到的分布:

While this is the distribution you get after multiplying two random variables:

        BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] * 
                                 RandomReal[{0, 1}, 50000], {50000}], 0.01]]

因此,两者都是随机的",但是它们的分布却大不相同.

So, both are "random", but their distribution is very different.

2 * Random()是均匀分布的:

        BarChart[BinCounts[2 * RandomReal[{0, 1}, 50000], 0.01]]

Random()+ Random()不是!

直方图

        BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] + 
                                 RandomReal[{0, 1}, 50000], {50000}], 0.01]]

中心极限定理

中心极限定理指出 Random()的总和趋向于正态分布.

The Central Limit Theorem

The Central Limit Theorem states that the sum of Random() tends to a normal distribution as terms increase.

仅需四个学期即可获得:

With just four terms you get:

的直方图

BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000] +
                   Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000],
                   {50000}],
         0.01]]  

在这里,您可以通过将1、2、4、6、10和20个均匀分布的随机变量相加来看到从均匀分布到正态分布的道路:

And here you can see the road from a uniform to a normal distribution by adding up 1, 2, 4, 6, 10 and 20 uniformly distributed random variables:

修改

一些学分

感谢 Thomas Ahle 在评论中指出,最后两幅图像所示的概率分布是被称为 Irwin-Hall分布

Thanks to Thomas Ahle for pointing out in the comments that the probability distributions shown in the last two images are known as the Irwin-Hall distribution

感谢 Heike 出色的 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆