I’m using a custom random number function rand48 in CUDA. The function does not allow an upperbound to be set, but I require the output to be between 0 and 1.
I guess I’m missing something but how would I convert the output to be between 0 and 1, the length of the number can change e.g. 697135872 would need to be divided by 100000000 and 29186668 would need to be divided by 100000000.
Thanks everyone
If your PRNG behaves like
randthen it generates numbers between 0 andRAND_MAXwith uniform probability. You just have to multiply by1.f/RAND_MAX.If you divide by different numbers in different cases, you will end up with non-uniform distribution.