random_shuffle种子 [英] random_shuffle seed
问题描述
我正在调用random_shuffle而不传入RandomNumberGenerator
并且每次重新启动程序时都会进行相同的随机播放。显然
我需要为内部随机数生成器播种。但是怎么样?我不能用b $ b找到任何办法,如果没有,那么内部
随机数发生器怎么有用?
谢谢,
-peter
I''m calling random_shuffle without passing in a RandomNumberGenerator
and getting the same shuffle every time I restart my program. Apparently
I need to seed the internal random number generator. But how? I can''t
find any way to do that, and if there is none, then how is the internal
random number generator useful?
Thanks,
-peter
推荐答案
" Peter Ammon" < PE ********* @ rocketmail.com>写道...
"Peter Ammon" <pe*********@rocketmail.com> wrote...
我正在调用random_shuffle而不传入RandomNumberGenerator
并且每次重新启动程序时都会进行相同的随机播放。显然
我需要播种内部随机数生成器。但是怎么样?我无法找到任何方法,如果没有,那么内部
随机数生成器如何有用?
I''m calling random_shuffle without passing in a RandomNumberGenerator
and getting the same shuffle every time I restart my program. Apparently
I need to seed the internal random number generator. But how? I can''t
find any way to do that, and if there is none, then how is the internal
random number generator useful?
了解''srand''的功能。
V
Read about ''srand'' function.
V
" Peter阿蒙" < PE ********* @ rocketmail.com>在消息中写道
news:bn ********** @ news.apple.com ...
"Peter Ammon" <pe*********@rocketmail.com> wrote in message
news:bn**********@news.apple.com...
我正在调用random_shuffle而没有传入一个RandomNumberGenerator
每次重新启动程序时都会进行相同的随机播放。显然
我需要播种内部随机数生成器。但是怎么样?我无法找到任何方法,如果没有,那么内部
随机数生成器如何有用呢?
谢谢,
-peter
I''m calling random_shuffle without passing in a RandomNumberGenerator
and getting the same shuffle every time I restart my program. Apparently
I need to seed the internal random number generator. But how? I can''t
find any way to do that, and if there is none, then how is the internal
random number generator useful?
Thanks,
-peter
查找srand()函数。虽然乍一看似乎很愚蠢,但是生成伪随机的生成器是一个生成伪随机的生成器。在
启动时使用相同种子的数字(例如,每次运行
程序时没有指定不同的种子),将为您提供可重复的随机序列。数字。这是
非常有用,如果你想调试模拟的行为
例子。
BTW你应该使用在您的计划中只有一次!
HTH
Chris
Look up the srand() function. Although it seems stupid at first glance, a
generator producing "pseudo-random" numbers using always the same seed at
startup (e.g. without specifying a different seed every time you run the
program), will give you a reproducable sequence of "random" numbers. This is
very helpful in case you want to debug the behavior of a simulation for
example.
BTW you should use srand only once in your program!!
HTH
Chris
Chris Theis写道:< br>
Chris Theis wrote:
Peter Ammon < PE ********* @ rocketmail.com>在消息中写道
新闻:bn ********** @ news.apple.com ...
"Peter Ammon" <pe*********@rocketmail.com> wrote in message
news:bn**********@news.apple.com...
我正在调用random_shuffle而没有传入一个RandomNumberGenerator
每次重新启动程序时都会进行相同的随机播放。显然
我需要播种内部随机数生成器。但是怎么样?我无法找到任何方法,如果没有,那么内部
随机数生成器如何有用呢?
谢谢,
-peter
I''m calling random_shuffle without passing in a RandomNumberGenerator
and getting the same shuffle every time I restart my program. Apparently
I need to seed the internal random number generator. But how? I can''t
find any way to do that, and if there is none, then how is the internal
random number generator useful?
Thanks,
-peter
查找srand()函数。虽然乍一看似乎是愚蠢的,但是生成伪随机的生成器。在启动时始终使用相同种子的数字(例如,每次运行
程序时未指定不同的种子),将为您提供可重复的随机序列。数字。如果您想调试模拟的行为,这非常有用。
顺便说一句,您应该只在程序中使用一次srand !!
HTH
Chris
Look up the srand() function. Although it seems stupid at first glance, a
generator producing "pseudo-random" numbers using always the same seed at
startup (e.g. without specifying a different seed every time you run the
program), will give you a reproducable sequence of "random" numbers. This is
very helpful in case you want to debug the behavior of a simulation for
example.
BTW you should use srand only once in your program!!
HTH
Chris
random_shuffle显然不必使用rand()作为其内部
PRNG ;看看我对Bazarov先生的回应。
-Peter
random_shuffle evidently doesn''t have to use rand() as its internal
PRNG; see my response to Mr. Bazarov.
-Peter
这篇关于random_shuffle种子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!