RSS Email Twitter GitHub Dribbble LinkedIn Facebook Instagram YouTube Google+ Pinterest Reddit icon

bloggR

Monte Carlo Simulations: Going parallel with the furrr package

In the last post I showed how to use purrr to perform a simple Monte Carlo simulation. Since simulation studies are usually computationally expensive, it is benifical to write efficient code and make use of parallelization. The latter even more important when working on a modern computer. My PC has a Ryzen 3700X CPU with 8 cores and 16 threads. For longer computations it would be a waste of ressources not to go parallel when possible.

Monte Carlo Simulations: for-loop vs. purrr::map()

Usually, I would use a simple for-loop to run small Monte Carlo simulations. For me, it is the most intuitive way. One can virtually see what happens in each iteration and how the results are produced. However, the students I am teaching (mostly economics and business with only a little to no programming knowledge) struggle to get it right. I am wondering if it would be beneficial to switch to a functional approach, e.