fix sample means example

master
Garrett Mills 5 years ago
parent e741c8de64
commit 9a406e001e

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

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

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

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

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

@ -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()

Loading…
Cancel
Save