From 64791f07623053d7f90976fba892206c92ba17f0 Mon Sep 17 00:00:00 2001 From: Garrett Mills Date: Wed, 1 May 2019 15:20:03 -0500 Subject: [PATCH] add sample means example --- demos/sample_means/generate_plots.R | 11 +++++++++++ demos/sample_means/slurm_submit_generate_plots.sh | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 demos/sample_means/generate_plots.R create mode 100644 demos/sample_means/slurm_submit_generate_plots.sh diff --git a/demos/sample_means/generate_plots.R b/demos/sample_means/generate_plots.R new file mode 100644 index 0000000..eb3d59d --- /dev/null +++ b/demos/sample_means/generate_plots.R @@ -0,0 +1,11 @@ +arg = commandArgs(TRUE) + +samples = rep(NA, 100000) +for ( i in 1:100000 ){ samples[i] = mean(rexp(40, 0.2)) } + +jpeg(paste('plots/', arg, '.jpg', sep="")) + +hist(samples, main="", prob=T) +lines(density(samples), col="darkblue", lwd=3) + +dev.off() diff --git a/demos/sample_means/slurm_submit_generate_plots.sh b/demos/sample_means/slurm_submit_generate_plots.sh new file mode 100644 index 0000000..feb5e40 --- /dev/null +++ b/demos/sample_means/slurm_submit_generate_plots.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=1 + +cd $SLURM_SUBMIT_DIR + +mkdir plots/ + +R --vanilla -f generate.R --args "plot$SLURM_ARRAY_TASK_ID"