m******t 发帖数: 4077 | 1 randn('state', s) - reset the state to s
这个到底是什么意思啊?
是说如果你连续run s次,出来的random number 都是一样的马? | s****h 发帖数: 921 | 2 我一般这样做:
rand('state', sum(100*clock));
由当前时间来确定初态。
要不然你每次打开matlab, randn输出的结果一样。
说白来了是pseudo-random. | h***n 发帖数: 36 | 3 All random number generator in MATLAB is pseudo random generator, so it
starts from a number and do certain operations to get another number. If
you start from the same place, e.g., s, you will always get same series of
random numbers.
In fact MATLAB currently has three random number generators.
If you use 'seed', you are using one of them, if you are using 'state', you
are using another one of them. The best one so far is 'twister', but it may
not be in randn yet.
【在 m******t 的大作中提到】 : randn('state', s) - reset the state to s : 这个到底是什么意思啊? : 是说如果你连续run s次,出来的random number 都是一样的马?
| r*****f 发帖数: 247 | 4 没明白, 我直接用randn产生一个1000*1的向量,但是不加任何 state, seed
每次出来的也不一样啊.并不是从同样的数字开始的
you
may
【在 h***n 的大作中提到】 : All random number generator in MATLAB is pseudo random generator, so it : starts from a number and do certain operations to get another number. If : you start from the same place, e.g., s, you will always get same series of : random numbers. : In fact MATLAB currently has three random number generators. : If you use 'seed', you are using one of them, if you are using 'state', you : are using another one of them. The best one so far is 'twister', but it may : not be in randn yet.
| c****g 发帖数: 6 | 5 s0 = rand('state') %returns the current state of the random number generator,
x = rand(10,1); % generate random number
s1 = rand('state') % returns the current state of the random number
generator
disp([s0,s1]) % you will see s0 and s1 are different,that means the state
changes each time you ran the random number generatror
s0 =rand('state');
x1 = rand;
x2 = rand;
rand('state',s0);
x3 = rand;
x1,x2,x3, $ you will see that x1 = x3, x1~=x2
【在 r*****f 的大作中提到】 : 没明白, 我直接用randn产生一个1000*1的向量,但是不加任何 state, seed : 每次出来的也不一样啊.并不是从同样的数字开始的 : : you : may
| r*****f 发帖数: 247 | 6 now that state change each time I ran the random generator, why should I
specificly use 'seed' or 'state' to manually change it?
generator,
【在 c****g 的大作中提到】 : s0 = rand('state') %returns the current state of the random number generator, : x = rand(10,1); % generate random number : s1 = rand('state') % returns the current state of the random number : generator : disp([s0,s1]) % you will see s0 and s1 are different,that means the state : changes each time you ran the random number generatror : s0 =rand('state'); : x1 = rand; : x2 = rand; : rand('state',s0);
| s****h 发帖数: 921 | 7 try:
close MATLAB
open MATLAB
input randn and record the number.
then close MATLAB and open MATLAB
input randn and see what happens. | h***n 发帖数: 36 | 8 Because sometimes you may want to reproduce the behavior.
【在 r*****f 的大作中提到】 : now that state change each time I ran the random generator, why should I : specificly use 'seed' or 'state' to manually change it? : : generator,
|
| m******t 发帖数: 4077 | 9 ok, 我理解的意思是如果你每次都从相同的state开始, 出来的结果就是一样的random
sequence, 但是randn('state', 100) 和randn('state', 1)除了是不同的state, 还有
区别马? 都是给定一个起始状态就是了吧.
generator,
【在 c****g 的大作中提到】 : s0 = rand('state') %returns the current state of the random number generator, : x = rand(10,1); % generate random number : s1 = rand('state') % returns the current state of the random number : generator : disp([s0,s1]) % you will see s0 and s1 are different,that means the state : changes each time you ran the random number generatror : s0 =rand('state'); : x1 = rand; : x2 = rand; : rand('state',s0);
| z*****n 发帖数: 7639 | 10 给一个seed并不能让输出变成真正的random,
seed只是改变了输出序列的开始值。
【在 s****h 的大作中提到】 : 我一般这样做: : rand('state', sum(100*clock)); : 由当前时间来确定初态。 : 要不然你每次打开matlab, randn输出的结果一样。 : 说白来了是pseudo-random.
| z*****n 发帖数: 7639 | 11 matlab的randn里面应该有随机化机制。我的经验跟你一样。
【在 r*****f 的大作中提到】 : 没明白, 我直接用randn产生一个1000*1的向量,但是不加任何 state, seed : 每次出来的也不一样啊.并不是从同样的数字开始的 : : you : may
|
|