我有一个matlab代码,其中包含一堆随机数,例如:unifrnd(0,1),normrnd(mu,sigma),这种功能会一遍又一遍地重复.
I have a matlab code which has a bunch of random numbers such as: unifrnd(0,1), normrnd(mu,sigma), this sort of functions get repeated over and over again.
有什么办法可以修复生成的随机数?意思是,一旦得到一些结果,我就运行代码,在第二次运行中,我得到不同的结果(如预期的那样).但是,我想尝试一些经验,如果可以修复初始种子,使两次运行的所有随机性都相同,那将非常有帮助.
Is there any way I can fix the random numbers that are generated? Meaning, I run the code once I get some results, on the second run I get different results (as expected). However, I want to make some experiences and it would be really helpful if I could fix the initial seed so that all randomness would be the same on the two runs.
谢谢, V
是否可以进行以下工作:rand('seed', 57)
edit: Would something like this work: rand('seed', 57)
推荐答案根据文档,
rng(seed);设置随机数生成器的种子.
sets the seed of the random number generator.
更多推荐
如何在Matlab中设置相同的初始种子随机数?
发布评论