Hi everybody,
I'm building a Monte Carlo simulation - not a gambling site, but a type of model that runs millions of times using a random number generator to pick a value for independent variables from a probability distribution that are then used in other calculations.
The inner loops of the model run millions of times and have to be blazingly fast or the model will take weeks, even months to run. We're writing the application in C# and I'm afraid that the overhead of the interpreter from intermediate code into machine code will be a killer.
Any suggestions as to a language I can use for the inner loops that compiles into fast machine code whose object code I can link back into the C# code?
Many thanks, Ned
Loading
Mike GoldPosted May 3, 2007, 1:11 PM
The only slow down may be garbage collection of large data.
Ned GoodhuePosted May 3, 2007, 10:23 AM
The problem is that this code has to run millions of times. If that code is going to be interpreted from intermediate code to machine code each time it runs, it will be too slow. I need this inner loop to be compiled down to machine code by a machine-specific compiler then linked into the C# shell.
I'm trying to figure out how best to do that.
Mike GoldPosted May 2, 2007, 2:27 PM
Are you trying to get a pure random number after millions of random generations or are you getting a million random numbers?
If you just want a loop that generates random numbers, why not spin it in a thread with some sort of sleep delay and have it run in parallel?
If you are looking for a more "random" random number, you can use the DateTime.Now.Ticks as a seed.