matlab seed函数_如何用matlab生成随机数函数

1. MATLAB 函数 rand

产生在区间 (0, 1)的均匀随机数,它是平均分布在 (0,1)之间。一个称为seed的值则是用来控制产生随机数的次数。均匀随机数函数的语法为rand(n),rand(m,n),其结果分别产生一矩阵含n×n个随机数和一矩阵含m×n的随机数。注意每次产生随机数的值都不会一样,这些值代表的是随机且不可预期的,这正是我们用随机数的目的。我们可利用这些随机数代入算式中,来表示某段讯号的不规则振幅或是某个事件出现的机率。均匀随机数其值平均的分布于一区间的特性可以从其统计密度函数(probabilitydensity function, PDF)说明。从其PDF分布类似长条图的分布,可以看出其每一个随机数值出现的机率皆相同,所以它被称为均匀随机数。

见以下的例子:

>> rand(1,6) % 第一次使用随机数产生器

ans =

0.2190 0.0470 0.6789 0.6793 0.9347 0.3835

>>hist(ans) % 看看长条图的长相

>>plot(ans) % 比较上个图与这个图有何差异?何者能代表不规则数据的分布

>> rand(1,6) % 第二次使用随机数产生器,注意每次产生的随机数值皆不同

ans =

0.5194 0.8310 0.0346 0.0535 0.5297 0.6711

因为每次随机数产生的值皆不同,如果因为验证算式需要确定所使用的随机数值是相同的,可以利用seed这个选项,用以设定使用计算随机数产生器的起始值,其语法为rand('seed',n),n的规定是。其中n=0有特别意义是使用第一次产生随机数值的起始值(=931316785

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
% Known encoding formats are the following FDSN codes: % 0: ASCII % 1: 16-bit integer % 2: 24-bit integer (untested) % 3: 32-bit integer % 4: IEEE float32 % 5: IEEE float64 % 10: Steim-1 % 11: Steim-2 % 12: GEOSCOPE 24-bit (untested) % 13: GEOSCOPE 16/3-bit gain ranged % 14: GEOSCOPE 16/4-bit gain ranged (untested) % 19: Steim-3 (alpha and untested) % % See also MKMSEED to export data in miniSEED format. % % % Author: Franois Beauducel % Institut de Physique du Globe de Paris % Created: 2010-09-17 % Updated: 2012-04-21 % % Acknowledgments: % Ljupco Jordanovski, Jean-Marie Saurel, Mohamed Boubacar, Jonathan Berger, % Shahid Ullah. % % References: % IRIS (2010), SEED Reference Manual: SEED Format Version 2.4, May 2010, % IFDSN/IRIS/USGS, http://www.iris.edu % Trabant C. (2010), libmseed: the Mini-SEED library, IRIS DMC. % Steim J.M. (1994), 'Steim' Compression, Quanterra Inc. % History: % [2012-04-21] % - Correct bug with Steim + little-endian coding % (thanks to Shahid Ullah) % [2012-03-21] % - Adds IDs for warning messages % [2011-11-10] % - Correct bug with multiple channel name length (thanks to % Jonathan Berger) % [2011-10-27] % - Add LocationIdentifier to X.ChannelFullName % [2011-10-24] % - Validation of IEEE double encoding (with PQL) % - Import/plot data even with file integrity problem (like PQL) % [2011-07-21] % - Validation of ASCII encoding format (logs) % - Blockettes are now stored in substructures below a single % field X.BLOCKETTES % - Add import of blockettes 500 and 2000 % - Accept multi-channel files with various data coding % [2010-10-16] % - Alpha-version of Steim-3 decoding... % - Extend output parameters with channel detection % - Add gaps and overlaps on plots % - Add possibility to force the plot % [2010-10-02] % - Add the input formats for GEOSCOPE multiplexed old data files % - Additional output argument with gap and overlap analysis % - Create a plot when no output argument are specified % - Optimize script coding (30 times faster STEIM decoding!) % % [2010-09-28] % - Correction of a problem with STEIM-1 nibble 3 decoding (one % 32-bit difference) % - Add reading of files without blockette 1000 with additional % input arguments (like Seismic Handler output files). % - Uses warning() function instead of fprintf().
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值