Exercise

# More tasks than workers

You will now parallelize your simple embarrassingly parallel application from a previous exercise. To repeatedly evaluate `mean_of_rnorm()`

that computes the mean of a set of random numbers, a sequential `for`

-loop solution looks as follows:

```
for(iter in seq_len(n_replicates))
result[iter] <- mean_of_rnorm(n_numbers_per_replicate)
```

The iterations are independent of one another. Thus, we can convert it into a parallel form. Notice that we are now distributing many more tasks (namely `n_replicates`

) than we have workers available.

The function `mean_of_rnorm()`

is preloaded, as is the `parallel`

library.

Instructions

**100 XP**

- Create a cluster object
`cl`

with two workers, and set`n_replicates`

to 50 and`n_numbers_per_replicate`

to 10000. - Evaluate
`mean_of_rnorm()`

in parallel, so that it is repeated`n_replicates`

times and in each evaluation it receives`n_numbers_per_replicate`

as its argument. - View results as a histogram.