MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / nrandd

Method nrandd

source/core/StarRandom.cpp:161–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161double RandomSource::nrandd(double stddev, double mean) {
162 double rand1, rand2, distSqr;
163 do {
164 rand1 = 2 * randd() - 1;
165 rand2 = 2 * randd() - 1;
166 distSqr = rand1 * rand1 + rand2 * rand2;
167 } while (distSqr >= 1);
168
169 double mapping = std::sqrt(-2 * std::log(distSqr) / distSqr);
170 return (rand1 * mapping * stddev + mean);
171}
172
173int64_t RandomSource::stochasticRound(double val) {
174 double fpart = val - floor(val);

Callers 2

nranddFunction · 0.80
TESTFunction · 0.80

Calls 1

randdFunction · 0.85

Tested by 1

TESTFunction · 0.64