SSブログ

R: parallelパッケージ その2 [統計]

R: parallelをつかってみるのつづき。mcparallel()を使ってみる。並行したRのプロセスをつくるとのこと。
library(boot)

n <- 10000
m <- 5000
c <- 3

x <- vector("list", c)
for (i in 1:c) {
  x[[i]] <- runif(n, 0, 1)
}

boot.fun <- function(data, index) {
  mean(data[index])
}

library(parallel)

r <- vector("list", c)
for (i in 1:c) {
  r[[i]] <- mcparallel(boot(x[[i]], boot.fun, m))
}
# wait
res <- mccollect(r)
print(res)

結果
$`99644`

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = x[[i]], statistic = boot.fun, R = m)


Bootstrap Statistics :
     original       bias    std. error
t1* 0.4946006 2.003117e-05 0.002872614

$`99645`

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = x[[i]], statistic = boot.fun, R = m)


Bootstrap Statistics :
     original        bias    std. error
t1* 0.4990066 -2.169221e-05 0.002894828

$`99646`

ORDINARY NONPARAMETRIC BOOTSTRAP


Call:
boot(data = x[[i]], statistic = boot.fun, R = m)


Bootstrap Statistics :
     original       bias    std. error
t1* 0.4987062 2.583383e-05 0.002893329

タグ:R
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

Facebook コメント

トラックバック 0