Exercise

Setting global variables

Here you will use a slight modification of the previous example, where instead of passing the mean and sd parameters as arguments, they will be defined in the worker's environment as global variables. You will use the clusterEvalQ() function again for the worker initialization.

As before, the parallel package and the cluster object cl are available in your workspace. A variant of myrdnorm() that uses global variables is shown in the script.

Instructions 1/2

undefined XP
    1
    2
  • Set the mean to 10 and the standard deviation, sd, to 5 (on the master node).
  • Use myrdnorm() to generate 1000 numbers.