Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

RandUniform_Direct bug or misunderstanding

gol
Beginner
307 Views

RandUniform_Direct takes its seed as a pointer to an unsigned int. While the doc doesn't clearly state it, I though that the idea of a pointer to a seed, instead of a seed value, was to be able to continue generating the random numbers from wherethe generatorwas left at.
RandUniform_Direct -does- modify the seed, so I was expecting there was a good reason behind this.

However, calling RandUniform_Direct on a block of let's say 16 single floats, doesn't produce the same results as calling RandUniform_Direct on a block of 8 floats, and then calling it again for the 8 remaining ones, using the seed that was output by the first.

Is it normal?
I thought that maybe RandUniform_Direct was using a double-seeded algo, the other values being stored in its state, and that for what I'm looking for I should be using the non-direct version. However the random stream has pretty predictable periods which is a hint that it's a simple single-seeded algo that's being used.

In fact, since I was replied before that RandUniform was guaranteed to be the same in future versions of IPP, maybe the doc should mention which algo is used, even for the sake of being able to generate the same randomness without IPP - for safety (but of course one could still look at the code in a debugger).


The doc is pretty clear about it for Tone_Direct (about the phase), but I don't see any reason for it to be different for RandUniform_Direct.

0 Kudos
3 Replies
Vladimir_Dudnik
Employee
307 Views

Hello,

With 'Direct' version of function you can't generate random sequence in more than one call with the same seed. The function use pointer to seed parameter to return arbitrary random number after you call it for the first time. So it simplify coding when you need to get new random sequence each call of this function.

The algorithm implemented in IPP random unifirm functions was derived from article G.Marsaglia, A.Zaman. Some portable very-long-period random number generators. //Computer in Physics, 8, #1, 1994, 117)

Regards,
Vladimir

0 Kudos
gol
Beginner
307 Views

Thanks, that clears it up.

Does it use the same constants as in the article?
namely (if that's the correct article I found):

typedef unsigned long int unlong;

unlong x=521288629, y=362436069, z=16163801, c=l,

n=1131199209;

ulong mzranl30

( long int s;

if (px+c) {s=y- (x+c) ; c=O;l

else { s=y-tx+c)-ia; c=l; )

x=y; y=z; return (z=s) + (n-69069*n+1013904243);

1;

void ra.n13set(ulong xx, ulong yy, ulong zz, long nn)

( x=x)(; y=yy; z=zz; n=nn; c=yxz; )

0 Kudos
Vladimir_Dudnik
Employee
307 Views

Hello,

implementation was derived on material from that article but is not just copying. Some coefficients are the same some are differs due to optimization.

Regards,
Vladimir

0 Kudos
Reply