- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
matlab之经典GUI文档
rand产生的是0到1(不包括1)的随机数.
matlab的rand函数生的是伪随机数,即由种子递推出来的,相同的种子,生成相同的随机数.
matlab刚运行起来时,种子都为初始值,因此每次第一次执行rand得到的随机数都是相同的.
1.多次运行,生成相同的随机数方法:
用rand(state,S)设定种子S为35阶向量,最简单的设为0就好
例:
rand(state,0);rand(10)
2. 任何生成相同的随机数方法:
试着产生和时间相关的随机数,种子与当前时间有关.
rand(state,sum(100*clock))
即:
rand(state,sum(100*clock)) ;rand(10)
只要执行rand(state,sum(100*clock)) ;的当前计算机时间不现,生成的随机值就不现.
也就是如果时间相同,生成的随机数还是会相同.
在你计算机速度足够快的情况下,试运行一下:
rand(state,sum(100*clock));A=rand(5,5);rand(state,sum(100*clock));B=rand(5,5);
A和B是相同.
所以建议再增加一个随机变量,变成:
rand(state,sum(100*clock)*rand(1));
?
?
%
据说matlab 的rand 函数还存在其它的根本性的问题,似乎是非随机性问题.
没具体研究及讨论,验证过,不感多言.
有兴趣的可以查阅:
A strong nonrandom pattern in Matlab default random number generator
?
Petr SavickyInstitute of Computer ScienceAcademy of Sciences of CRCzech Republicsavicky@cs.cas.czSeptember 16, 2006AbstractThe default random number generator in Matlab versions between 5 and at least7.3 (R2006b) has a strong dependence between the numbers zi+1, zi+16, zi+28 in thegenerated sequence. In particular, there is no index i such that the inequalitieszi+1 1/4, 1/4 zi+16 1/2, and 1/2 zi+28 are satisfied simultaneously. Thisfact is proved as a consequence of the recurrence relation defining the generator. Arandom sequence satisfies the inequalities with probability 1/32. Another exampledemonstrating the dependence is a simple function f with values ?1 and 1, such thatthe correlation between f(zi+1, zi+16) and sign(zi+28 ? 1/2) is at least 0.416, while itshould be zero.A simple distribution on three variables that closely approximates the jointdistribution of zi+1, zi+16, zi+28 is described. The region of zero density in theapproximating distribution has volume 4/21 in the three dimensional unit cube. Forevery integer 1 k 10, there is a parallelepiped with edges 1/2k+1, 1/2k and 1/2k+1,where the density of the distribution is 2k. Numerical simulation confirms that thedistribution of the original generator matches the approximation within small randomerr
您可能关注的文档
最近下载
- 反渗透系统操作维护技术手册1.pdf VIP
- 智慧物流园区可视化综合管控平台建设方案.pptx VIP
- 4.3 去括号(课件)青岛版(2024)数学七年级上册.pptx VIP
- DB3502Z 5009-2018-海绵城市建设技术标准图集.pdf VIP
- 上海市闵行区2024年六年级《语文》上册期中试题与参考答案.docx VIP
- 风力发电机组电气安装作业指导书.docx VIP
- 安全文明施工承诺书.docx VIP
- 构建和谐的亲子关系主题班会PPT课件.pptx VIP
- 国际人才流动与治理报告——以美国为枢纽的分析2024.docx VIP
- 勿忘国耻,珍爱和平--国家公祭日主题班会课件.pptx
文档评论(0)