Main Content

塔罗尔尔

控制高阵列的随机数生成

Description

塔罗尔尔('default')将高阵列计算用于其默认值的随机数生成器的设置。产生的随机数与您重新启动MATLAB一样®

塔塔尔尔('洗牌')根据当前时间设置随机数发生器的种子。每次生成它们时想要不同的随机数序列时,请使用此语法。

塔罗尔尔(种子设置随机数发生器的起始点或种子。当您想要产生可预测的数字序列时,请使用此语法。

塔罗尔尔(种子generatoror塔罗尔尔('洗牌',generator选择随机数生成器。例如,Tallrng(0,'MLFG6331_64')

=塔尔格尔尔将随机数生成器的当前状态作为结构返回。使用该结构将随机数发生器恢复到捕获状态的稍后塔罗尔尔(州)

塔罗尔尔(restores the state of the random number generator using settings previously captured with州=塔尔格尔尔尔

Examples

全部收缩

捕捉发生器设置,生成一个数组of random numbers, and then restore the generator to the initial settings to create predictable arrays of random numbers.

保存随机数生成器的当前状态。

州=塔尔格尔尔尔
州=塑造with fields:Type: 'threefry' Seed: 0 StreamIndex: 1 Substream: 1

使用一个高大的随机数阵列使用Arrayfun.

t =高(零(10,1));n1 = arrayfun(@(x)x + randn,t)
n1 = 10x1 tall array ? ? ? ? ? ? ? ? : :

将生成器恢复到先前状态并重新生成随机数阵列。两个阵列n1andn2are equal.

Tallrng(州)n2 = arrayfun(@(x)x + randn,t)
n2 = 10x1 tall array ? ? ? ? ? ? ? ? : :

输入参数

全部收缩

随机数种子那specified as a nonnegative integer. The seed specifies the starting point for the algorithm to generate random numbers. Specify the seed when you want reproducible results.

种子的最大值是232.-1

Example:塔罗尔尔(3)

随机数生成器,指定为此表中的随机数生成器之一。您可以指定常规或便利名称。

名称 便利名称 Description
'threefry4x64_20'(默认) 'threefry' 三级4x64发电机20轮
'MRG32K3A' '幸福父母'

组合多个递归发生器

'mlfg6331_64' 'multFibonacci'

乘法滞后的斐波纳契发生器

'philox4x32_10' 'Philox' Philox 4x32发电机10轮

塔罗尔尔万博1manbetx支持具有多个流和子流支持的随机数生成器。看到Choosing a Random Number Generator有关MATLAB中的可用生成器的完整列表。

Example:Tallrng(0,'MLFG6331_64')

以前的随机数生成状态,指定为先前使用的结构州=塔尔格尔尔尔

Example:州=塔尔格尔尔尔captures the current state of the random number generator, and塔罗尔尔(州)将生成器恢复到这些设置。

数据类型:塑造

输出参数

全部收缩

随机数发生器州那returned as a structure with these fields.

领域 Description 示例值
Type Type of random number generator 'threefry'
种子 Number indicating the starting point for the algorithm (for reproducibility) 0.
StreamIndex. Index indicating the associated global stream 1
底层 指示相关子流的索引 1

Example:州=塔尔格尔尔尔captures the current state of the random number generator, and塔罗尔尔(州)将生成器恢复到这些设置。

数据类型:塑造

Tips

  • 如果您有统计和机器学习工具箱™,那么塔罗尔尔控制诸如此类的随机数datasample.CVPartition.那andtreebagger在高阵列计算期间生成。

Compatibility Considerations

展开全部

R2019A中的行为发生了变化

也可以看看

|

在R2017B中介绍