0

I am trying to use CURAND library to generate random numbers which are completely independent of each other. Hence I want to give different seeds to each thread. So, Question 1: How do I give different seeds to each thread?(Is there some time function in CUDA which I can use?)

Now I also want to generate this random number between a range i.e 0 to 10000. How do I accomplish that to happen.

Currently I am using curand_normal (as I want to have numbers from normal distribution) but its giving me negative and same numbers which I do not want.

user1439690
  • 659
  • 1
  • 11
  • 26

1 Answers1

0

Setting different seeds is not a statistically sound way to get independent (non-correlated) random numbers (with any single random number generator). You would be better off selecting different sub-sequences of a single sequence, and most random number libraries will allow you to do that, including cuRAND.

Check out the examples in the CUDA SDK, for example the EstimatePiP or EstimatePiInlineP examples use cuRAND to generate pseudo-random numbers.

For the second part of your question, as mentioned in the cuRAND manual the curand_normal() routines return Normally distributed numbers with mean 0.0 and standard deviation 1.0 (i.e. Standard Normal Distribution). Clearly that means that you will have ~50% negative numbers.

It doesn't make sense to specify a fixed range along with the Normal distribution. You either want some other distribution (e.g. Uniform) with the fixed range or else you want the Normal distribution with a specific mean and standard distribution. To get from the Standard Normal to your target mean/std.dev. you simply multiply the random draw by the target standard deviation and add the target mean.

Tom
  • 20,852
  • 4
  • 42
  • 54
  • Thanks a lot.. So you mean to say if I want independent random numbers then I can use the same seed but need to use different sub-sequences? – user1439690 Sep 14 '12 at 13:09
  • 1
    There are a few ways of getting independent random sequences: block-splitting, leap-frogging and tuned parameter sets. The first two are effectively sub-sequences of the main sequence, the third is a bit different (and more complex). Different RNGs lend themselves to different methods. The cuRAND manual goes into detail on using sub-sequences so it's a good place to start. – Tom Sep 14 '12 at 13:29