rnorm函数使用哪种算法 [英] Which algorithm used by the rnorm function
问题描述
rnorm
函数默认使用哪种算法来生成标准正态分布的随机数?
Which algorithm is using by the rnorm
function by default to generate standard-normally distributed random numbers?
推荐答案
请参见?RNGkind
.默认为反演算法:
See ?RNGkind
. The default is an inversion algorithm:
normal.kind
可以是"Kinderman-Ramage","Buggy Kinderman-Ramage"(不是 对于set.seed
),"Ahrens-Dieter","Box-Muller","Inversion"( 默认)或用户提供". (有关反转,请参见qnorm
.)1.7.1之前的版本中使用的Kinderman-Ramage生成器 (现在称为越野车")具有多个近似误差,并且仅应 用于复制旧结果. "Box-Muller"生成器是 当成对的法线被生成并顺序返回时,它是有状态的. 无论何时选择状态,都会重置该状态(即使它是当前状态也是如此) 普通生成器)以及更改种类的时间.
normal.kind
can be "Kinderman-Ramage", "Buggy Kinderman-Ramage" (not forset.seed
), "Ahrens-Dieter", "Box-Muller", "Inversion" (the default), or "user-supplied". (For inversion, see the reference inqnorm
.) The Kinderman-Ramage generator used in versions prior to 1.7.1 (now called "Buggy") had several approximation errors and should only be used for reproduction of old results. The "Box-Muller" generator is stateful as pairs of normals are generated and returned sequentially. The state is reset whenever it is selected (even if it is the current normal generator) and when kind is changed.
您可以通过以下方式更改算法
You can change the algorithm by
RNGkind(normal.kind = "Box-Muller")
您可以通过查看RNGkind()[2]
来找到当前设置的内容.
You can find what is currently set by looking at RNGkind()[2]
.
这篇关于rnorm函数使用哪种算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!