PRNG proposal

Cyrille Berger cberger at cberger.net
Sun Dec 14 09:35:34 CET 2008


Well unfortunately it doesn't seem to have nice white noise property:

I tried various seed, here is one example of the stat I got:
mean =  9.2188e+18
max =  1.8447e+19
min = 3.4784e+13
median =  9.2184e+18
std =  5.3239e+18
var =  2.8344e+37
(mean - (max+min)/ 2) = -4.6155e+15

The two things I find worrying is the high median, it indicates that half the 
values are in the range [ 9.2184e+18; 1.8447e+19] while the other half is 
spread on [ 3.4784e+13; 9.2184e+18 ]. And in our case, the white noise 
property concerning the mean would (mean - (max+min)/ 2) == 0. The hardest 
white noise property to get right is the autocorrelation.

In attachement you can find what I used to generate files for octave.

On Friday 12 December 2008, Matthew Woehlke wrote:
> Ok, after fiddling more with integer-only algorithms, here's something
> that isn't *too* horribly many operations, that's non-recursive and only
> uses only integers. It seems to look okay*, but hasn't been tested for
> any sort of distribution theory.
>
> quint64 myRand48(quint64 n, quint64 a, quint64 b)
> {
>      return ((n * a) + b); // needed?? & 0xFFFFFFFFFFFF;
> }
>
> quint64 myRandom(int x, int y, int seed)
> {
>      quint64 n = (quint64(x) * 1103515249) + (quint64(y) * 91573268041)
> + seed;
>      n = myRand48(n, 8759824322359, 13);
>      n = (n >> 24) ^ (n << 24);
>      n = myRand48(n, 200560490131, 2707);
>      n ^= x ^ (y * 39916801);
>      return myRand48(n, 26329792769470687, 62017);
> }
>
> (* the lower several bits are still obviously patterned. As long as the
> upper ~40 bits are favored this should be ok, but taking the result
> &0xFF won't work well.)
>
> I won't feel hurt if y'all don't like this. I'd be *thrilled* if anyone
> can improve it :-). It's just something that /might/ (and I do stress
> "might") be usable as a pure-integer algorithm.
>
> (In its favor - though I think this is true of the current algorithm
> also - it achieves one of my goals, which is that changing the seed
> completely changes the output.)
>
> --
> Matthew
> Please do not quote my e-mail address unobfuscated in message bodies.



-- 
Cyrille Berger
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: text/x-c++src
Size: 1052 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20081214/75de4479/attachment.cpp 


More information about the kimageshop mailing list