MCPcopy Create free account
hub / github.com/catboost/catboost / StdNormalDistribution

Function StdNormalDistribution

util/random/normal.h:12–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 */
11template <typename T, typename TRng>
12static inline T StdNormalDistribution(TRng&& rng) noexcept {
13 T x;
14 T y;
15 T r;
16
17 do {
18 x = (T)rng.GenRandReal1() * T(2) - T(1);
19 y = (T)rng.GenRandReal1() * T(2) - T(1);
20 r = x * x + y * y;
21 } while (r > T(1) || r <= T(0));
22
23 return x * std::sqrt(-T(2) * std::log(r) / r);
24}
25
26template <typename T, typename TRng>
27static inline T NormalDistribution(TRng&& rng, T m, T d) noexcept {

Callers

nothing calls this directly

Calls 4

GenRandReal1Method · 0.80
TClass · 0.50
sqrtFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected