| 177 | } |
| 178 | |
| 179 | float random_standard_normal_f(bitgen_t *bitgen_state) { |
| 180 | uint32_t r; |
| 181 | int sign; |
| 182 | uint32_t rabs; |
| 183 | int idx; |
| 184 | float x, xx, yy; |
| 185 | for (;;) { |
| 186 | /* r = n23sb8 */ |
| 187 | r = next_uint32(bitgen_state); |
| 188 | idx = r & 0xff; |
| 189 | sign = (r >> 8) & 0x1; |
| 190 | rabs = (r >> 9) & 0x0007fffff; |
| 191 | x = rabs * wi_float[idx]; |
| 192 | if (sign & 0x1) |
| 193 | x = -x; |
| 194 | if (rabs < ki_float[idx]) |
| 195 | return x; /* # 99.3% of the time return here */ |
| 196 | if (idx == 0) { |
| 197 | for (;;) { |
| 198 | /* Switch to 1.0 - U to avoid log(0.0), see GH 13361 */ |
| 199 | xx = -ziggurat_nor_inv_r_f * npy_log1pf(-next_float(bitgen_state)); |
| 200 | yy = -npy_log1pf(-next_float(bitgen_state)); |
| 201 | if (yy + yy > xx * xx) |
| 202 | return ((rabs >> 8) & 0x1) ? -(ziggurat_nor_r_f + xx) |
| 203 | : ziggurat_nor_r_f + xx; |
| 204 | } |
| 205 | } else { |
| 206 | if (((fi_float[idx - 1] - fi_float[idx]) * next_float(bitgen_state) + |
| 207 | fi_float[idx]) < exp(-0.5 * x * x)) |
| 208 | return x; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | void random_standard_normal_fill_f(bitgen_t *bitgen_state, npy_intp cnt, float *out) { |
| 214 | npy_intp i; |
no test coverage detected