0
votes

I am using gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11) compiler. Uniform real distribution function does not work in it. Is there some way I may generate numbers between 0 to 1 [0,1] in my present compiler according to

  1. Uniform random distribution
  2. Gaussian distribution
  3. Exponential distribution.

I can not upgrade the compiler my project has a lot of dependencies on current 4.4.7 version. Either C or C++ will work for me.

1
There is no standard function to do that before C++11 (only plain rand). Why you can't get modern compiler? If it is your home project it should be easy. - senfen
Perhaps it has <tr1/random>? - chris
Are you looking for a c solution, or a c++. They solution could be different depending on the language - Degustaf
Have you looked at Boost? - NathanOliver
My condolences for being stuck with this very old compiler version.. - stefan

1 Answers

1
votes

If you don't have the libraries, I would grab a copy of "Numerical Recipes in C" and write them yourself. Since they are copyrighted, I cannot copy them here. But chapter 7 has what you are looking for.

My copy is dated; however, still great for this stuff. 7.1 Uniform Deviates, 7.2 Normal Deviates, and 7.3 Poisson, Gamma, and Binomial Deviates.

--jon