montecarlo1-capp-region1
Monte Carlo simulation is a mathematical technique that allows us to make intelligent estimates about the risk in quantitative analysis and decision making. It is widely used in fields such as finance, project management, engineering, research and development, transportation, and so on. Monte Carlo simulation provides the decision maker with a set of possible outcomes and the probabilities associated with them for any choice of action. It shows the extreme possibilities as well as the middle-of-the-road possibilities.
The way Monte Carlo works is that it performs risk analysis. It does this by building models of possible results by using a probability distribution for any factor that has inherent uncertainity. Then, it calculates the results several times, each time using a different set of random values for the probability functions.Depending on how complex the problem is, a Monte Carlo simulation could involve thousands of recalculations before it completes. Commonly used probability distributions are: normal ("bell curve") distribution, lognormal distribution, uniform distribution, triangular distribution, etc.
Code Snippet// d=256, M=1000 // float type arrays: r, u1, t, u2, x.
for(i=0; i < M*d; i++){ r[i]=sqrtf(-2.0f* logf(u1[i])); t[i]=2.0f*M_PI*(u2[i]); x[i]=r[i]*cosf(t[i]); }