# 怎样用R生成随机数_r生成正态分布随机数

3600℃

R软件一个显著的优点是它提供了丰富的随机数发生器，比SAS、Matlab方面很多，比Excel更不知方便到哪里去了。这无疑为统计学、工程学以及寿险精算学提供了很大的方便，比如我们要产生200个服从正态分布的随机数，在R里面用只需要键入“rnorm(200)”即可得到。操作如下：

>rnorm(200)

[1] -0.12071839  0.05257376 -0.23671186 -0.71413741  2.17362525 -0.25102710
[7] -1.41124223  1.78816754  0.95697026 -1.73518078 -0.71141662  1.27847876
[13] -1.50472436 -0.55267534  0.46788900  0.32977779  0.37641009 -1.22411512
[19] -1.82099431 -1.50026288……

rnorm()函数更通用的用法是rnorm(n,mean,sd),其中n为要产生随机数的个数，mean为所产生随机数的总体所具有的均值，sd是所产生的随机数的总体所具有的标准差。

>rnorm(n=100,mean=2,sd=3)

>rnorm(100,2,3)

rexp The Exponential Distribution

rf The F Distribution

rgamma The Gamma Distribution

rgeom The Geometric Distribution

rhyper The Hypergeometric Distribution

rlnorm The Log Normal Distribution

rlogis The Logistic Distribution

rmultinom The Multinomial Distribution

rnbinom The Negative Binomial Distribution

rnorm The Normal Distribution

rpois The Poisson Distribution

rsignrank Distribution of the Wilcoxon Signed Rank Statistic

rt The Student t Distribution

runif The Uniform Distribution

rweibull The Weibull Distribution

rwilcox Distribution of the Wilcoxon Rank Sum Statistic

rexp The Exponential Distribution

rf The F Distribution

rgamma The Gamma Distribution

rgeom The Geometric Distribution

rhyper The Hypergeometric Distribution

rlnorm The Log Normal Distribution

rlogis The Logistic Distribution

rmultinom The Multinomial Distribution

rnbinom The Negative Binomial Distribution

rnorm The Normal Distribution

rpois The Poisson Distribution

rsignrank Distribution of the Wilcoxon Signed Rank Statistic

rt The Student t Distribution

runif The Uniform Distribution

rweibull The Weibull Distribution

rwilcox Distribution of the Wilcoxon Rank Sum Statistic

Pearson (χ2)

• 在线沟通，请点我在线咨询

• 咨询热线：
000-000-0000
客服qq：
3285157825