<small id='4Q4Ns'></small><noframes id='4Q4Ns'>

    <i id='4Q4Ns'><tr id='4Q4Ns'><dt id='4Q4Ns'><q id='4Q4Ns'><span id='4Q4Ns'><b id='4Q4Ns'><form id='4Q4Ns'><ins id='4Q4Ns'></ins><ul id='4Q4Ns'></ul><sub id='4Q4Ns'></sub></form><legend id='4Q4Ns'></legend><bdo id='4Q4Ns'><pre id='4Q4Ns'><center id='4Q4Ns'></center></pre></bdo></b><th id='4Q4Ns'></th></span></q></dt></tr></i><div id='4Q4Ns'><tfoot id='4Q4Ns'></tfoot><dl id='4Q4Ns'><fieldset id='4Q4Ns'></fieldset></dl></div>
  1. <tfoot id='4Q4Ns'></tfoot>
        <bdo id='4Q4Ns'></bdo><ul id='4Q4Ns'></ul>
    1. <legend id='4Q4Ns'><style id='4Q4Ns'><dir id='4Q4Ns'><q id='4Q4Ns'></q></dir></style></legend>

      就生成随机数而言,种子是什么?

      时间:2023-06-05
      • <bdo id='WQz1y'></bdo><ul id='WQz1y'></ul>

        <tfoot id='WQz1y'></tfoot>

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

        <legend id='WQz1y'><style id='WQz1y'><dir id='WQz1y'><q id='WQz1y'></q></dir></style></legend>

          <tbody id='WQz1y'></tbody>
          • <i id='WQz1y'><tr id='WQz1y'><dt id='WQz1y'><q id='WQz1y'><span id='WQz1y'><b id='WQz1y'><form id='WQz1y'><ins id='WQz1y'></ins><ul id='WQz1y'></ul><sub id='WQz1y'></sub></form><legend id='WQz1y'></legend><bdo id='WQz1y'><pre id='WQz1y'><center id='WQz1y'></center></pre></bdo></b><th id='WQz1y'></th></span></q></dt></tr></i><div id='WQz1y'><tfoot id='WQz1y'></tfoot><dl id='WQz1y'><fieldset id='WQz1y'></fieldset></dl></div>
                本文介绍了就生成随机数而言,种子是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                就生成随机数而言,种子是什么?

                What is a seed in terms of generating a random number?

                我需要生成数百到数千个随机数,我已经阅读了很多关于使用种子"的信息.什么是种子?是随机数从哪里开始的种子吗?例如,如果我将种子设置为 5,它会生成从 5 到我的限制的数字吗?例如,它永远不会给我 3.

                I need to generate hundreds to thousands of random numbers, I have read a lot about using a "seed". What is a seed? Is a seed where the random numbers start from? For example if I set my seed to be 5 will it generate numbers from 5 to whatever my limit is? So it will never give me 3 for example.

                我使用的是 C++,所以如果你提供任何示例,如果它是在 C++ 中就好了.

                I am using C++, so if you provide any examples it'd be nice if it was in C++.

                谢谢!

                推荐答案

                现实中通常所说的随机数序列是伪随机"数序列,因为这些值是使用确定性算法计算的,而概率没有实际作用角色.

                What is normally called a random number sequence in reality is a "pseudo-random" number sequence because the values are computed using a deterministic algorithm and probability plays no real role.

                种子"是序列的起点,保证如果您从同一个种子开始,您将获得相同的数字序列.例如,这对于调试非常有用(当您在程序中查找错误时,您需要能够重现问题并研究它,非确定性程序将更难调试,因为每次运行都会不同).

                The "seed" is a starting point for the sequence and the guarantee is that if you start from the same seed you will get the same sequence of numbers. This is very useful for example for debugging (when you are looking for an error in a program you need to be able to reproduce the problem and study it, a non-deterministic program would be much harder to debug because every run would be different).

                如果您只需要一个随机的数字序列并且不需要重现它,那么只需使用当前时间作为种子...例如:

                If you need just a random sequence of numbers and don't need to reproduce it then simply use current time as seed... for example with:

                srand(time(NULL));
                

                这篇关于就生成随机数而言,种子是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:1.0 是 std::generate_canonical 的有效输出吗? 下一篇:改变uniform_int_distribution的范围

                相关文章

                <legend id='oT5cR'><style id='oT5cR'><dir id='oT5cR'><q id='oT5cR'></q></dir></style></legend>

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

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

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