reword comments

This commit is contained in:
NunoSempere 2023-09-27 13:51:05 +01:00
parent fa714f91ae
commit 015d33adca

View File

@ -22,13 +22,10 @@
// Pseudo Random number generator
uint64_t xorshift32(uint32_t* seed)
{
// The reader isn't expected to understand this code immediately;
// read the linked Wikipedia page!
// Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"
// See <https://stackoverflow.com/questions/53886131/how-does-xorshift32-works>
// https://en.wikipedia.org/wiki/Xorshift
// Also some drama: <https://www.pcg-random.org/posts/on-vignas-pcg-critique.html>, <https://prng.di.unimi.it/>
// for floats
uint64_t x = *seed;
x ^= x << 13;
x ^= x >> 17;
@ -38,7 +35,7 @@ uint64_t xorshift32(uint32_t* seed)
uint64_t xorshift64(uint64_t* seed)
{
// same as above, but for generating doubles
// same as above, but for generating doubles instead of floats
uint64_t x = *seed;
x ^= x << 13;
x ^= x >> 7;
@ -79,7 +76,7 @@ double sample_lognormal(double logmean, double logstd, uint64_t* seed)
return exp(sample_normal(logmean, logstd, seed));
}
inline double sample_normal_from_95_confidence_interval(double low, double high, uint64_t* seed)
inline double sample_normal_from_90_confidence_interval(double low, double high, uint64_t* seed)
{
// Explanation of key idea:
// 1. We know that the 90% confidence interval of the unit normal is
@ -112,7 +109,7 @@ double sample_to(double low, double high, uint64_t* seed)
// Then see code for sample_normal_from_95_confidence_interval
double loglow = logf(low);
double loghigh = logf(high);
return exp(sample_normal_from_95_confidence_interval(loglow, loghigh, seed));
return exp(sample_normal_from_90_confidence_interval(loglow, loghigh, seed));
}
double sample_gamma(double alpha, uint64_t* seed)