<bdo id='UyIcH'></bdo><ul id='UyIcH'></ul>
  • <i id='UyIcH'><tr id='UyIcH'><dt id='UyIcH'><q id='UyIcH'><span id='UyIcH'><b id='UyIcH'><form id='UyIcH'><ins id='UyIcH'></ins><ul id='UyIcH'></ul><sub id='UyIcH'></sub></form><legend id='UyIcH'></legend><bdo id='UyIcH'><pre id='UyIcH'><center id='UyIcH'></center></pre></bdo></b><th id='UyIcH'></th></span></q></dt></tr></i><div id='UyIcH'><tfoot id='UyIcH'></tfoot><dl id='UyIcH'><fieldset id='UyIcH'></fieldset></dl></div>

  • <small id='UyIcH'></small><noframes id='UyIcH'>

    <legend id='UyIcH'><style id='UyIcH'><dir id='UyIcH'><q id='UyIcH'></q></dir></style></legend>
      <tfoot id='UyIcH'></tfoot>

      1. 如果我们在不同的机器上播种 c++11 mt19937 相同,我们会得到相同的随机数序列吗

        时间:2023-06-05

            <tbody id='cIdfN'></tbody>

            1. <tfoot id='cIdfN'></tfoot><legend id='cIdfN'><style id='cIdfN'><dir id='cIdfN'><q id='cIdfN'></q></dir></style></legend>

              <small id='cIdfN'></small><noframes id='cIdfN'>

              <i id='cIdfN'><tr id='cIdfN'><dt id='cIdfN'><q id='cIdfN'><span id='cIdfN'><b id='cIdfN'><form id='cIdfN'><ins id='cIdfN'></ins><ul id='cIdfN'></ul><sub id='cIdfN'></sub></form><legend id='cIdfN'></legend><bdo id='cIdfN'><pre id='cIdfN'><center id='cIdfN'></center></pre></bdo></b><th id='cIdfN'></th></span></q></dt></tr></i><div id='cIdfN'><tfoot id='cIdfN'></tfoot><dl id='cIdfN'><fieldset id='cIdfN'></fieldset></dl></div>
              • <bdo id='cIdfN'></bdo><ul id='cIdfN'></ul>

                • 本文介绍了如果我们在不同的机器上播种 c++11 mt19937 相同,我们会得到相同的随机数序列吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  受this和类似问题的启发,我想了解 mt19937C++11 中的伪数生成器的行为,当在两台不同的机器上时,它以相同的输入作为种子.

                  Inspired from this and the similar questions, I want to learn how does mt19937 pseudo-number generator in C++11 behaves, when in two separate machines, it is seeded with the same input.

                  换句话说,假设我们有以下代码;

                  In other words, say we have the following code;

                  std::mt19937 gen{ourSeed};
                  std::uniform_int_distribution<int> dest{0, 10000};
                  int randNumber = dist(gen);
                  

                  如果我们在不同的时间在不同的机器上尝试这段代码,我们会得到相同序列的 randNumber 值还是每次不同的序列?

                  If we try this code on different machines at different times, will we get the same sequence of randNumber values or a different sequence each time ?

                  无论哪种情况,为什么会这样?

                  And in either case, why this is the case ?

                  另一个问题:

                  不管种子如何,这段代码会无限生成随机数吗?我的意思是比如说,如果我们在一个连续运行几个月的程序中使用这块代码,会不会出现数字的生成问题或数字的统一性问题?

                  Regardless of the seed, will this code generate randomly numbers infinitely ? I mean for example, if we use this block of code in a program that runs for months without stopping, will there be any problem in the generation of the number or in the uniformity of the numbers ?

                  推荐答案

                  generator 将生成相同的值.

                  发行版 可能不会,至少在不同的编译器或库版本中是这样.该标准没有详细说明他们的行为.如果您想要编译器和库版本之间的稳定性,则必须推出自己的发行版.

                  The distributions may not, at least with different compilers or library versions. The standard did not specify their behaviour to that level of detail. If you want stability between compilers and library versions, you have to roll your own distribution.

                  除非库/编译器更改,否则将以相同的顺序返回相同的值.但是,如果您愿意编写自己的发行版.

                  Barring library/compiler changes, that will return the same values in the same sequence. But if you care write your own distribution.

                  ...

                  所有 PRNG 都有模式和句点.mt19937 以其周期 2^19937-1 命名,这不太可能是问题.但其他模式可以发展.MT PRNG 对许多统计测试都很稳健,但它们在密码学上不是安全的 PRNG.

                  All PRNGs have patterns and periods. mt19937 is named after its period of 2^19937-1, which is unlikely to be a problem. But other patterns can develop. MT PRNGs are robust against many statistical tests, but they are not crytographically secure PRNGs.

                  因此,如果您运行数月,这将是一个问题,这取决于您发现问题的具体细节.但是,mt19937 将是比您可能自己编写的任何内容都更好的 PRNG.但假设攻击者可以根据过去的证据预测其未来的行为.

                  So it being a problem if you run for months will depend on specific details of what you'd find to be a problem. However, mt19937 is going to be a better PRNG than anything you are likely to write yourself. But assume attackers can predict its future behaviour from past evidence.

                  这篇关于如果我们在不同的机器上播种 c++11 mt19937 相同,我们会得到相同的随机数序列吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 C++ 中使用 rand() 函数的正确方法是什么? 下一篇:如何生成线程安全的统一随机数?

                  相关文章

                    <bdo id='PdYGm'></bdo><ul id='PdYGm'></ul>

                  <i id='PdYGm'><tr id='PdYGm'><dt id='PdYGm'><q id='PdYGm'><span id='PdYGm'><b id='PdYGm'><form id='PdYGm'><ins id='PdYGm'></ins><ul id='PdYGm'></ul><sub id='PdYGm'></sub></form><legend id='PdYGm'></legend><bdo id='PdYGm'><pre id='PdYGm'><center id='PdYGm'></center></pre></bdo></b><th id='PdYGm'></th></span></q></dt></tr></i><div id='PdYGm'><tfoot id='PdYGm'></tfoot><dl id='PdYGm'><fieldset id='PdYGm'></fieldset></dl></div>

                • <small id='PdYGm'></small><noframes id='PdYGm'>

                  <tfoot id='PdYGm'></tfoot>

                    1. <legend id='PdYGm'><style id='PdYGm'><dir id='PdYGm'><q id='PdYGm'></q></dir></style></legend>