抛硬币发生器

发布于 2024-12-25 10:26:13 字数 92 浏览 2 评论 0原文

如果编写一个程序来模拟抛硬币,当查看结果时,50% 的硬币正面朝上或反面朝上,你们认为结果会怎样?主要是当前 10 次抛硬币都是反面时,正面朝上的比例会更高,反之亦然吗?

what do you guys think will be the outcome if a program is coded to simulate a coin flip where there is a 50% of the coin landing either heads or tails when the results are looked at; Mainly will there be a higher % of the coin flips landing heads when the previous 10 flips were tails and vice versa?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

做个ˇ局外人 2025-01-01 10:26:14

这实际上取决于使用什么机制来生成随机数。比如说,如果使用线性同余生成器...

...那么显然任何给定的生成数字都依赖于前面的数字。输出的质量还取决于与机制结合使用的参数(例如,如果上述方法中的“m”使用较小的值,则质量会很差......或者如果您的种子值是高度可预测的)。

尽管计算机仅生成伪随机数,但某些算法满足统计随机性的测试(即没有可辨别的图案)并且可以安全使用。

如果您担心生成的数字的随机性,您应该研究在您的特定上下文中用于生成它们的实际方法。有关更多信息,请查看维基百科

This really depends on what mechanism is being used to generate the random numbers. If, say, a linear congruential generator is used...

... then clearly any given generated number is dependent on the one that preceded. The quality of the output also depends on what parameters are used in conjunction with the mechanism (e.g. if a small value was used for "m" in the above method, the quality would be poor... or if your seed value was highly predictable).

Despite the fact that computers only generate pseudo-random numbers, some algorithms satisfy the tests for statistical randomness (i.e. have no discernible patterns) and can be used safely.

If you are that concerned about the randomness of your generated numbers, you should look into the actual method being used to generate them within your specific context. For more information, take a look at Wikipedia.

看海 2025-01-01 10:26:14

如果你的编程正确,无论之前的投掷次数如何,落在硬币两侧的机会应该是相等的(50%)......

If you program it correctly, the chance of landing on either side of the coin should be equal(50%), regardless of previous flips...

蓝天 2025-01-01 10:26:14

在任何给定的抛掷中,正面/反面的概率始终为 50%。连续获得 x 次正面(或任何指定的正面/反面组合)的概率为 0.5^x(因为每次抛掷都是独立于其他的)。

The probability of heads/tails is always 50% on any given toss. The probability of getting x heads (or any specified combination of heads/tails) in a row is 0.5^x (because each toss is independent of the others).

剑心龙吟 2025-01-01 10:26:14

我的理解是正确的,你是问如果编写一个程序给每个选项 50% 的机会,是否会有更多的“正面”结果或“反面”结果?

从统计上看,如果您多次运行该程序,每一方都会平均,并且您将得到相同数量的正面和反面结果。 (根据您选择的语言,您可能必须为随机发生器提供种子以保证真正的随机性。)

I'm I am understanding you correctly, you are asking if there will be more "heads" results or "tails" results if a program is written to give each option a 50% chance?

Statistically, if you run the program a number of times, each side will average out and you'll have an equal number of heads and tails results. (Depending on your language of choice, you may have to seed the randomizer to guarantee true randomness.)

帅气尐潴 2025-01-01 10:26:14

我认为这取决于伪随机数生成器的性能。
仅十次翻转,结果可能毫无意义......
但是,如果您有一个好的算法来生成伪随机数,并且您使用 n try 扩展此实验,其中“n”非常大,则概率仍保持为 0.5 (50%)。
这是因为统计数据没有记忆

I suppose that it depends on the goodness of the pseudo-random number generator.
On only ten flips, the results may be meaningless...
But if you have a good algorithm to generate pseudo-random number, and you extend this experiment with n try where "n" is a significantly large large, the probability still remain 0.5 (50%).
This because the statistic has no memory

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文