lundi 10 février 2020

How does numpy's implementation random normal distribution work?

The implementation if numpy.random.normal is in the source code of numpy:

double random_standard_normal(bitgen_t *bitgen_state);

I'm curious about how these lines work:

/* r = e3n52sb8 */
    r = next_uint64(bitgen_state);
    idx = r & 0xff;
    r >>= 8;
    sign = r & 0x1;
    rabs = (r >> 1) & 0x000fffffffffffff;
    x = rabs * wi_double[idx];
    if (sign & 0x1)
      x = -x;



Aucun commentaire:

Enregistrer un commentaire