MCPcopy
hub / github.com/numpy/numpy / gauss_from_uint

Function gauss_from_uint

numpy/random/tests/test_direct.py:118–140  ·  view source on GitHub ↗
(x, n, bits)

Source from the content-addressed store, hash-verified

116
117
118def 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
143def test_seedsequence():

Callers 1

test_gauss_invMethod · 0.85

Calls 3

uniform_from_uint64Function · 0.85
uniform_from_uint32Function · 0.85
uniform_from_dsfmtFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…