MCPcopy Create free account
hub / github.com/PythonOT/POT / fragmented_hypercube

Function fragmented_hypercube

test/test_dr.py:117–131  ·  view source on GitHub ↗
(n, d, dim, rng)

Source from the content-addressed store, hash-verified

115 dim = 3
116
117 def fragmented_hypercube(n, d, dim, rng):
118 assert dim <= d
119 assert dim >= 1
120 assert dim == int(dim)
121
122 a = (1.0 / n) * np.ones(n)
123 b = (1.0 / n) * np.ones(n)
124
125 # First measure : uniform on the hypercube
126 X = rng.uniform(-1, 1, size=(n, d))
127
128 # Second measure : fragmentation
129 tmp_y = rng.uniform(-1, 1, size=(n, d))
130 Y = tmp_y + 2 * np.sign(tmp_y) * np.array(dim * [1] + (d - dim) * [0])
131 return a, b, X, Y
132
133 rng = np.random.RandomState(42)
134 a, b, X, Y = fragmented_hypercube(n, d, dim, rng)

Callers 1

test_prwFunction · 0.85

Calls 2

onesMethod · 0.45
signMethod · 0.45

Tested by

no test coverage detected