fix sample means example

This commit is contained in:
Garrett Mills 2019-05-01 15:40:04 -05:00
parent e741c8de64
commit 9a406e001e
8 changed files with 27 additions and 7 deletions

1
cluster Submodule

@ -0,0 +1 @@
Subproject commit d556690348d9667689247704c8a2ddc20e35e632

View File

@ -0,0 +1 @@
Host: cluster-master Rank(ID): 1 of Size: 2 on comm 1

View File

@ -0,0 +1 @@
Host: cluster-master Rank(ID): 1 of Size: 2 on comm 1

View File

@ -0,0 +1 @@
Host: cluster-master Rank(ID): 1 of Size: 2 on comm 1

View File

@ -0,0 +1 @@
Host: cluster-master Rank(ID): 1 of Size: 2 on comm 1

View File

@ -1,11 +1,26 @@
arg = commandArgs(TRUE)
if ( !is.loaded("mpi_initialize") ){
library(Rmpi)
}
samples = rep(NA, 100000)
for ( i in 1:100000 ){ samples[i] = mean(rexp(40, 0.2)) }
number_of_plots = 5
nodes = mpi.universe.size()
mpi.spawn.Rslaves(nslaves=nodes)
jpeg(paste('plots/', arg, '.jpg', sep=""))
generate_plot <- function(filename){
samples = rep(NA, 100000)
for ( i in 1:100000 ){ samples[i] = mean(rexp(40, 0.2)) }
jpeg(paste('plots/', filename, '.jpg', sep=""))
hist(samples, main="", prob=T)
lines(density(samples), col="darkblue", lwd=3)
dev.off()
}
hist(samples, main="", prob=T)
lines(density(samples), col="darkblue", lwd=3)
samples = 1:number_of_plots
dev.off()
mpi.apply(samples, generate_plot)
mpi.close.Rslaves()
mpi.quit()