[英]How to generate random number that start with the same value in MATLAB and C#
I am writing the same program in C# and MATLAB. 我在C#和MATLAB中编写相同的程序。 The only issue I am facing is the different values generated in MATLAB and C#, although I am providing the same seed value.
尽管我提供相同的种子值,但我面临的唯一问题是在MATLAB和C#中生成的值不同。
In other words, the random numbers generated by both compilers are not matching. 换句话说,两个编译器生成的随机数都不匹配。
For example: 例如:
C#: C#:
Random rand = new Random(10);
double val = rand.Next(1, 100);
it starting random number is: 95 它的起始随机数是:95
MATLAB: MATLAB:
rng(10);
r2 = randi([1 100],1,1)
While it starting random number is: 77 而它的起始随机数是:77
Can anyone help me? 谁能帮我?
How to let both compilers begin with the same random number? 如何让两个编译器以相同的随机数开头?
编写生成随机对象的函数,并使用相同的参数对其进行初始化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.