Reproduce the bootstrap
You work for an online stock brokerage. Your firm is developing an Android app that provides general price ranges for stocks sold by the firm. A bootstrapping function, boot_price(), is available for you to calculate monthly price ranges.
To test the reproducibility of this function in parallel, you have decided to apply this function to every element of a list, ls_micro. Each element of this list is a vector of average daily Microsoft stock prices for a given month.
The parallel package has been loaded for you.
Latihan ini adalah bagian dari kursus
Parallel Programming in R
Petunjuk latihan
- Set a seed value of
321for thecl1cluster to do the first run. - Set the same seed value for the
cl2cluster to do the second run. - Test if outputs
result1andresult2are the same.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
cl1 <- makeCluster(4)
# Set 321 as the seed value for the first run
___(___, ___)
result1 <- parLapply(cl1, ls_micro, boot_price)
stopCluster(cl1)
cl2 <- makeCluster(4)
# Set the same seed value for the second run
___(___, ___)
result2 <- parLapply(cl2, ls_micro, boot_price)
stopCluster(cl2)
# Test if outputs are the same
___(___, ___)