curand_normal2

Hi,

im trying to use curand_normal2 inside a kernel of mine but I have a problem.As you can see below i store the result from the curand_normal2() in a float2 variable.The problem is that the numbers generated vary inside (-7,7). This variation is huge for my application.It would be ideal if Ι could limit it inside (0,1).

__global__ void kernel(... , .... , .... , .... , .... , .... ,unsigned long long seed) {

.....

.....

curandStateXORWOW_t localState;  //I tried curandState too 

float2 no;

.....

curand_init(seed , blockIdx.x*BLOCK_SIZE+threadIdx.x, 0,&localState);

.....

.....

for(k=0;k<L;k++)

{

.....

no=curand_normal2(&localState);

...

}

I know that with something like this:

no.x=powf(no.x/7,2);

i would nearly overcome the problem but

1)it takes so much computing time

2)Not normal distribution.Most of the numbers are near zero

PS

kernel(120,192)

L=5000

in case it matters

Thanks for your time

Are you sure that you want normally distributed numbers (as in a Gaussian distribution), rather than uniformly distributed numbers? I’m not aware of any applications where you want a Gaussian distribution limited to the range [0, 1).