Dynamic 2D array
I am trying to make a Monte-Carlo simulation in C++, and in that respect I need to store two values x and y in a 2D array.
Here is the situation: I have a loop running until some condition is satisfied. For ever iteration I want to write a pair of values (x, y) to my array, but the problem is that I don't know how many iterations there will be until the loop stops.
So my question is how I can make a 2D-array dynamically?
Thanks for any help.
Have you considered using std::vector, this will grow as required.
Are the ranges of x and y somehow dependent on your number of iterations?
I thought the general idea of MC was "throwing random darts at a dartboard" and then seeing how many meet some criterion (distance from centre) to give you some approximate answer to some value (say PI).
Thanks, they did the trick.
Originally Posted by jimblumberg
They do depend on the number of iterations (on average) in my case. Yes, MC can be used for stuff like that (evaluating integrals numerically, estimating Pi, etc..), but those are merely simple examples of what stochastic processes can be used for.
Originally Posted by Salem
Thanks for the help.