I´m implementing the Xorshift generators and others to compare their performances on my system - Windows and Linux.
https://en.wikipedia.org/wiki/Xorshift
I´m just now checking the generators with 64 bit states, like the xorshift64star from the wikipedia (here with my changes to trace the error)
double xorshift64star() {
uint64_t x = global_state[0]; /* The state must be seeded with a nonzero value. */
x ^= x >> 12; // a
x ^= x << 25; // b
x ^= x >> 27; // c
global_state[0] = x;
auto u64val = x * 0x2545F4914F6CDD1D;
double dval = (double)u64val;
return dval;
}
However, running on an online compiler https://www.onlinegdb.com/ the double value returned is always 0 or 3.1148823182455562e-317
I haven´t been able to find a solution on how to make the output from this function to be normalize into a [0,1] uniform distribution, without losing much precision and entropy.
What is the "corect" transformation I would have to do the output?
Aucun commentaire:
Enregistrer un commentaire