Generated (staged) function to avoid initializing an array multiple times for Monte Carlo simulations

Thank you, Chris, for your prompt response. Your example is very helpful (I’m learning a lot here).