> runif(1)
#生成一个(0,1)上的均匀分布随机数
[1] 0.6661981
> runif(10)
#生成10个
(0,1)上的均匀分布随机数
[1] 0.95549241 0.99039799 0.28050893 0.31159335 0.72820064 0.06589717
[7] 0.37308805 0.04962709 0.27343763 0.79214013
> runif(1, min=-3, max=3)
#生成一个(-3,3)上的均匀分布随机数
[1] -2.727779
> rnorm(1)
#生成一个标准正态分布随机数
[1] 1.213485
> rnorm(1, mean=100, sd=15)
#生成一个期望为100、方差为15的正态分布随机数
[1] 95.1548
> rbinom(1, size=10, prob=0.5)
#二项分布
[1] 5
> rpois(1, lambda=10)
#泊松分布
[1] 8
> rexp(1,rate=0.1)
#指数分布
[1] 1.249201
> rgamma(1,shape=2,rate=0.1) #伽马分布
[1] 14.55554
> rnorm(3,mean=c(-10,0,10),sd=1)
#生成3个正态分布随机数,短向量参数会被循环使用
[1] -9.842395 -0.879867 9.010954
> mean <- rnorm(100,mean=0,sd=0.2)
> rnorm(100, mean=mean,sd=1)
#期望正好是随机数
[1] -1.052897262 0.221461850 -0.391345118 0.224137213 0.272316033
[6] 1.287885891 0.154256313 0.096518858 1.402515345 -0.086878082
[11] 1.002132092 0.916728945 1.342576389 -1.071619311 1.297544301
[16] 1.387240593 -1.674475109 1.407482715 0.311735706 -1.366705423
[21] 0.803543073 -0.326333753 -0.360611295 0.475175531 -0.613969929
[26] 2.261266453 -1.160133626 -0.403582653 1.897664201 1.468270109
[31] -1.025354481 0.606690162 0.084401001 -0.183696647 -0.839342033
[36] -0.364455734 1.012103726 0.946516131 -0.933246453 1.439233089
[41] 0.593591199 -1.294765798 0.930443702 0.466275095 -0.813447324
[46] 0.330044251 0.876620530 1.634362828 0.698450712 0.677788432
[51] -0.196174869 -0.792442561 1.054596917 -0.307024277 -0.272191958
[56] 0.560267901 0.606007971 -1.403108666 -0.418905820 1.282634712
[61] -0.007488274 -0.773510972 1.311583769 0.454041783 -0.398655750
[66] 0.123545586 -1.162592616 -1.058055558 0.897592415 -1.138545684
[71] 1.229995820 -1.177410537 -1.094428425 -1.415597422 -0.443472272
[76] -0.984424892 0.590845060 1.659746115 -0.570441036 -1.318351570
[81] 0.155129207 1.010362126 0.922164178 1.143866716 0.387691775
[86] -1.600127641 0.887398901 0.670208984 -0.228769412 0.388753831
[91] -0.104620974 1.014887355 -0.973183677 0.046801521 0.083479447
[96] -1.289070363 -1.293016055 -1.056618614 1.495699705 0.498614068
>