Matlab rand 随机函数
发布:石油博客 | 发布时间: 2008年5月5日最近用到matlab的rand函数。其实matlab中的随机函数并不是真正意义上的随机函数。某网友称 一组真正的随机数的生成的计算量已经远大于一个一般的个人电脑所能承受的水平(也有生成几个数的运算量较小的算法,不过生成个数受算法限制)。所以说Matlab的随机数是伪随机数,但在一定的信度之下是可以看作真正的随机数的。以前好像我也用vb的时候用到随机函数,不过都忘记了,囧。
首先来看看matlab自带的rand帮助:
RAND Uniformly distributed random numbers. 标准化分布的随机数
RAND(N) is an N-by-N matrix with random entries, chosen from a uniform distribution on the interval (0.0,1.0). rand(N)为随机生成一个在【0,1】之间的n维随机矩阵。
RAND(M,N) and RAND([M,N]) are M-by-N matrices with random entries.随机生成一个在【0,1】之间的m,n维随机矩阵。
RAND(M,N,P,...) or RAND([M,N,P,...]) generate random arrays.
RAND with no arguments is a scalar whose value changes each time it is referenced. RAND(SIZE(A)) is the same size as A.
RAND produces pseudo-random numbers. The sequence of numbers generated is determined by the state of the generator. Since MATLAB resets the state at start-up, the sequence of numbers generated will be the same unless the state is changed. matlab的随机数算法是通过一个“种子”递推出来的, 种子在程序初始的时候都一样。
S = RAND('state') is a 35-element vector containing the current state of the uniform generator. RAND('state',S) resets the state to S.
RAND('state',0) resets the generator to its initial state. 重新恢复初始状态,刚运行matlab时候的状态
RAND('state',J), for integer J, resets the generator to its J-th state. 安排种子产生第j个状态
RAND('state',sum(100*clock)) resets it to a different state each time.根据时间产生不同的随机数
- 相关文章:
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。





