From: vortse a on
You will have to trade speed for memory. Break up your problem into chunks your memory can manage and loop through them.

As I see it, you want to perform P^R calculations for each combination of 2 variables, having P and R levels respectively. Since MC simulations are independent of eachother (otherwise we are talking about random walks) you don't have to do all computations simulataneously. You could break up the PxRx(P^R) matrix any way you want.

Unless your problem is actually about computing permutations (i.e. your are creating a lookup table for a subsequent MC simulation), in which case you cannot be arbitrary in the way you are subdividing your problem. However, it seems to me counterproductive to compute such a large lookup table; these are effective if the number of computations they require is much less than these of the MC simulation.

Do I make any sense to you?
From: Mark Shore on
There's no need to create an enormous array of values for Monte Carlo simulations. Simply generate your independent parameters with the desired distribution(s) on a run-by-run basis, then append them and the dependent variable(s) to a results file.

As vortse a notes, why generate a huge lookup table here? And as John points out, there are ways to solve the problem more artfully.