I have a loop. Inside the loop, in each iteration, I need to draw a number from U[0,1]. How can I use openmp, and also make sure that the random number generating process is not contaminated?
I got suggestion that I need a thread-safe random number generator, which may or may not be the solution to my problem.
My question is very related to another one, with a slight difference that I want to draw from a coninuum U[0,1]. Additionally, I don't know how to seed generator by thread, can someone please write a line of code?
[0, large_int]
, then convert to your preferred floating type and divide bylarge_int
, e.g.double random_float = (double) random_int / large_int
. – Sightseeing