Returns a normal random number with mean 0 and standard deviation 1 */
| 127 | |
| 128 | /** Returns a normal random number with mean 0 and standard deviation 1 */ |
| 129 | inline float normal() { |
| 130 | // Box-Muller transform |
| 131 | float radius = std::sqrt(-2.f * std::log(1.f - get<float>())); |
| 132 | float theta = 2.f * M_PI * get<float>(); |
| 133 | return radius * std::sin(theta); |
| 134 | |
| 135 | // // Central Limit Theorem |
| 136 | // const int n = 8; |
| 137 | // float sum = 0.0; |
| 138 | // for (int i = 0; i < n; i++) { |
| 139 | // sum += get<float>(); |
| 140 | // } |
| 141 | // return (sum - n / 2.f) / std::sqrt(n / 12.f); |
| 142 | } |
| 143 | |
| 144 | /** Fills an array with random bytes. */ |
| 145 | inline void buffer(uint8_t* out, size_t len) { |
no test coverage detected