Matlab 没有 randint,Matlab_learning_4(rand randn randint函数 )「建议收藏」

||matlab中rand函数是产生0到1的随机分布1>、RAND:Uniformlydistributedrandomnumbers.标准化分布的随机数2>、RAND(N)isanN-by-Nmatrixwithrandomentries,chosenfromauniformdistributionontheinterval(0.0,1.0…

大家好,又见面了,我是你们的朋友全栈君。

||matlab 中 rand 函数是产生0到1的随机分布

1>、RAND:Uniformly distributed random numbers.

标准化分布的随机数

2>、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维随机矩阵。

3>、RAND(M,N) and RAND([M,N]) are M-by-N matrices with random entries.

rand(M,N) and rand([M,N])随机生成一个在【0,1】之间的m,n维随机矩阵。

4>、RAND(M,N,P,…) or RAND([M,N,P,…]) generate random arrays.

rand(M,N,P) and rand([M,N])随机生成 P 个在【0,1】之间的m,n维随机矩阵。 5>、RAND with no arguments is a scalar whose value changes each time itis referenced. RAND(SIZE(A)) is the same size as A. 没有参数的rand是一个标量,它的值在每次被引用时都改变。rand( size(A) )是与 A 具有相同尺寸。6>、RAND produces pseudo-random numbers.The sequence of numbersgenerated is determined by the state of the                                        generator.Since MATLABresets the state at start-up, the sequence of numbers generated willbe the same unless the state                        is changed.

rand 产生伪随机数。生成的序列数由生成器的状态决定。由于 MATLAB 启动时重置状态,生成的序列数都是一样的除非状态改变。

7>、S = RAND(‘state’) is a 35-element vector containing the current stateof the uniform generator.RAND(‘state’,S) resets the                            state to S. 8>、RAND(‘state’,0) resets the generator to its initial state.

重新恢复初始状态,刚运行matlab时候的状态

9>、RAND(‘state’,J), for integer J, resets the generator to its J-th state.

安排种子产生第 j 个状态

10>、RAND(‘state’,sum(100*clock)) resets it to a different state each time.

根据时间产生不同的随机数 ~~~~~~~~~~~~~~~~~~~~~~rand above~~~~~~~~~~~~~~~~~~~~~~~~~~

>> x = rand(1,10)

x =

Columns 1 through 6

0.3786 0.8116 0.5328 0.3507 0.9390 0.8759

Columns 7 through 10

0.5502 0.6225 0.5870 0.2077

(2)function2:randn

||matlab中 randn 函数是产生标准正态分布

1>、RANDN产生正态分布数的语法:

标准化分布的随机数 ;

RANDN(N) :产生N× N的矩阵,其元素是按正态分布的数组;

RANDN(M,N) and RANDN([M,N]):产生M×N的矩阵;

RANDN(M,N,P,…) or RANDN([M,N,P…])产生随机序列;

2>、RANDN产生伪随机数的语法:

S = RANDN(‘state’) 是一个二元向量,包括标准发生器的状态;

RANDN(‘state’,S):设置发生器的状态为S(即标准状态);

RANDN(‘state’,0):设置发生器的初始状态;

RANDN(‘state’,J):J为整数,设置发生器到J阶状态;

3>、MATlAB 4.X应用一个单独的种子来产生随机数:

RANDN(‘seed’,0) and RANDN(‘seed’,J)作用与RANDN(‘state’,0)和RANDN(‘state’,J)一样,但使用Matlab 4.x随机数发生器。

RANDN(‘seed’):返回MATlAB 4.X发生器的当前种子。

>> x = randn(1,10)

x =

Columns 1 through 6

-0.1623 -0.1461 -0.5320 1.6821 -0.8757 -0.4838

Columns 7 through 10

-0.7120 -1.1742 -0.1922 -0.2741

(3)function3:randint

matlab 中 randint 是产生整数随机数,默认为 0 和 1

>> x = randi(1,10)

x =

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1

>> x = randint(1,10)

Warning: This is an obsolete function and may be removed in the

future.

Please use RANDI instead.

To disable this warning, type

warning(‘off’,’comm:obsolete:randint’).

x =

1 1 1 0 1 0 1 1 0 0

>> x = RANDI(1,10)

Undefined function ‘RANDI’ for input arguments of type ‘double’.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127667.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 以太坊私有链搭建_eth节点搭建

    以太坊私有链搭建_eth节点搭建Johnsir亲传不作任何商业用途首先创建三个文件夹分别为三个节点每个文件夹准备好一个存放数据的文件夹然后进入John1cmd进入puppeth后面的直接回车就可以到这步开始导出导出后文件夹多了四个文件主要用到的就是jhgeth.json其他三个可有可无geth–datadir”./jhdata”–networkid112233initjhgeth.json初始化创世块获取到geth…

    2022年10月7日
    0
  • cisco交换机常用命令[通俗易懂]

    一台全新交换机,不同模式命令大全交换机基本状态显示及各个状态切换:hostname>用户模式hostname#特权模式hostname(config)#全局配置模式hostname(config-if)#接口或者vlan多个接口配置模式hostname(vlan)#…

    2022年4月7日
    45
  • b4什么意思_f0是什么车

    b4什么意思_f0是什么车AndroidEagleEyeAnXposedandadbibasedmodulewhichiscapableofhookingbothJavaandNativemethodstargetingAndroidOS.Relatedinformationofthehookedmethodswillbeloggedastheoutput.Us…

    2022年8月16日
    2
  • c+ explicit_staticint与int的区别

    c+ explicit_staticint与int的区别C++ explicit关键字详解首先, C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 跟它相对应的另一个关键字是implicit, 意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式).那么显示声明的构造函数和隐式声明的有什么区别呢? 我们来看下面的例子:class CxString // 没有使用…

    2022年8月18日
    3
  • zookeeper集群安装配置

    zookeeper集群安装配置

    2021年11月15日
    41
  • tfs使用教程_tf.truncated_normal

    tfs使用教程_tf.truncated_normal一、如何删除工作项   1、使用Tfs管理员账户登录   2、使用Cmd打开命令行窗口        如果是32位系统,cd”C:/ProgramFiles/MicrosoftVisualStudio10.0/Common7/IDE”        64位系统则       cd”C:/ProgramFiles(x86)/MicrosoftVisualStudio10.0/Common7/IDE”   3、使用witadmin.exedestroywi命令,按下面的方式

    2022年9月23日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号