Beginning October 3, 2012 and largely depending on the rare breaks available while working on customer projects, this site is occassionally being edited and enlarged — We would enjoy welcoming you again on this page:
Complex Systems
(First published Sept. 17, 2012. Last updated and extended Sept. 23, 2013)
1. IntroductionBeginning mid-October 2012, this page will be devoted to publish material on some selected aspects of complex systems like, for example, Monte Carlo simulations, elementary aspects of stochastics, fractal systems, Computational Physics / Numerics etc.Interested readers are invited to visit this site again. 2. Elementary Questions and AnswersSome elementary questions and their answers can be found here:» Elementary Questions and Answers 3. First Remarks on Random Number Algorithms, Monte Carlo Simulations, etc.In the few algorithms considered during the next months, we will needN independent random numbers where N may be a large number. One particularly simple way of generating N independent sequences of random numbers may consist in using N instances of a good enough one-dimensional random number generator each initialized with a different seed. One especially good example of a random generator with an exceptionally large period of 2^{19937}-1 is nowadays given by Makoto Matsumoto's and Takuji Nishimura's Mersenne Twister algorithm. At the time of this writing, the Mersenne Twister sources were available free of charge on M.Matsumoto's excellent homepage:» www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html Link to Mersenne Twister homepage For those not using a recent C++11 compiler with its built-in implementation of the Mersenne Twister algorithms, we are recommending to use the code found on the above web site and use this to generate an N -dimensional sequence of random numbers. For brevity's sake, the Mersenne Twister sources are not repeated here. Instead, we are hinting on how the author of this page has been using N instances of another one-dimensional random generator in a simple C++ class. By way of example, we assume that we intend to use the C++ programming language for generating N independent series of uniform deviates of type double on the real interval [0,1) using a C++ class, henceforth called CStochRan1 , which is making use of a one-dimensional random generator member function, called ran1(long *lseed) , where *lseed be a pointer to the random seed (note that the class definition would be more complicated in a real example; the following code snippets are just meant to show one of several possible ways for coding N independent random generators; solving real problems means that the code needs to be adjusted and extended according to the problem's needs):
class CStochRan1
An N -dimensional generalization may then be coded using a class definition similar to the following example:class CStochRanN
where CStochRan1 is the beforementioned class describing a one-dimensional random generator; lseedArray a long integer pointer to random seeds used by the one-dimensional algorithm; and Ndim the current number of dimensions which may be large.The constructor CStochRanN(unsigned int N, long *lseeds) takes two arguments which are, respectively, the number, N , of independent random numbers, and a long pointer to an array containing N seeds. We are using malloc(.,.) to allocate the memory needed on the heap, create N instances of class CStochRan1 , and initialize the array containing the random seeds:CStochRanN::CStochRanN(unsigned int N, long *lseeds)
The destructor, ~CStochRanN(void) , takes care of deleting the CStochRan1 instances and freeing the memory previously allocated:CStochRanN::~CStochRanN(void)
We are using two overloaded versions of the random number generator program. The first prototype allows for modifying the random seeds while being invocated. The resulting N random numbers, each the result of invoking a ran1(.) instance, are being accessed by pointer *r :void CStochRanN::ranN(long *lseed, double *r)
The second version may be used without modifying the random seeds on the fly: void CStochRanN::ranN(double *r)
The other methods, used for retrieving the number of independent random numbers and the value of the seeds, are just given for reference: inline unsigned int CStochRanN::GetDim(void)
Having available N independent random generators has given us a simple start for using this and similar code within our future example programs.To be continued... 4. LinksYou may find additional information on complex systems by visiting the pages of the Complex Systems Society. At the time of this writing, their web site was accessible by following this link:» Link to the Complex Systems Society Please note again that this RD-AVENUE^{®} site is not in any way related to this or other societies but is instead reflecting the personal view of its author only. RD-AVENUE^{®} is a registered trademark of Dr. Rudolf R.H. Dittrich in Germany; all rights reserved. |