(x, n, bits)
| 116 | |
| 117 | |
| 118 | def gauss_from_uint(x, n, bits): |
| 119 | if bits in (64, 63): |
| 120 | doubles = uniform_from_uint64(x) |
| 121 | elif bits == 32: |
| 122 | doubles = uniform_from_uint32(x) |
| 123 | else: # bits == 'dsfmt' |
| 124 | doubles = uniform_from_dsfmt(x) |
| 125 | gauss = [] |
| 126 | loc = 0 |
| 127 | x1 = x2 = 0.0 |
| 128 | while len(gauss) < n: |
| 129 | r2 = 2 |
| 130 | while r2 >= 1.0 or r2 == 0.0: |
| 131 | x1 = 2.0 * doubles[loc] - 1.0 |
| 132 | x2 = 2.0 * doubles[loc + 1] - 1.0 |
| 133 | r2 = x1 * x1 + x2 * x2 |
| 134 | loc += 2 |
| 135 | |
| 136 | f = np.sqrt(-2.0 * np.log(r2) / r2) |
| 137 | gauss.append(f * x2) |
| 138 | gauss.append(f * x1) |
| 139 | |
| 140 | return gauss[:n] |
| 141 | |
| 142 | |
| 143 | def test_seedsequence(): |
no test coverage detected
searching dependent graphs…