R:rnorm不能模拟正确的数字

时间:2016-02-12 23:45:48

标签: r

当我尝试模拟一堆正常的变量时,我得到了奇怪的结果。我有足够的记忆来容纳这些。

N <- 2000
h1 <- 1000 * (1 - 0.9)

length(rnorm(N*h1,0,1)) == N*h1
[1] FALSE

>length(rnorm(3,0,1)) == 3
[1] TRUE

我讨厌R

CURIOSER和CURIOSER:

> N<-2000
> h1 <- 100
> length(rnorm(N*h1))
[1] 200000
> h1 <- 1000 * (1 - 0.9)
> length(rnorm(N*h1))
[1] 199999


> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] colorout_1.1-1

loaded via a namespace (and not attached):
[1] tools_3.2.3

我的.Rprofile中没有任何内容,除了:

library(colorout)

wideScreen <- function(howWide=Sys.getenv("COLUMNS")) {
    options(width=as.integer(howWide))
}

0 个答案:

没有答案