(x, n, bits)
| 105 | |
| 106 | |
| 107 | def gauss_from_uint(x, n, bits): |
| 108 | if bits in (64, 63): |
| 109 | doubles = uniform_from_uint64(x) |
| 110 | elif bits == 32: |
| 111 | doubles = uniform_from_uint32(x) |
| 112 | else: # bits == 'dsfmt' |
| 113 | doubles = uniform_from_dsfmt(x) |
| 114 | gauss = [] |
| 115 | loc = 0 |
| 116 | x1 = x2 = 0.0 |
| 117 | while len(gauss) < n: |
| 118 | r2 = 2 |
| 119 | while r2 >= 1.0 or r2 == 0.0: |
| 120 | x1 = 2.0 * doubles[loc] - 1.0 |
| 121 | x2 = 2.0 * doubles[loc + 1] - 1.0 |
| 122 | r2 = x1 * x1 + x2 * x2 |
| 123 | loc += 2 |
| 124 | |
| 125 | f = np.sqrt(-2.0 * np.log(r2) / r2) |
| 126 | gauss.append(f * x2) |
| 127 | gauss.append(f * x1) |
| 128 | |
| 129 | return gauss[:n] |
| 130 | |
| 131 | |
| 132 | def test_seedsequence(): |
no test coverage detected