Commit 77dc8316 authored by Steven Cordwell's avatar Steven Cordwell
Browse files

if exampleRand is sparse, then return create a transition matrix that is about 1/3 dense

parent 45e0e919
......@@ -540,10 +540,14 @@ def exampleRand(S, A, is_sparse=False, mask=None):
# if the user hasn't specified a mask, then we will make a random one now
if mask is None:
mask = rand(A, S, S)
for a in range(A):
if is_sparse:
# create a mask that has roughly two thirds of the cells set to 0
mask[mask <= 2/3] = 0
mask[mask > 2/3] = 1
else:
r = random()
mask[a][mask[a, :, :] < r] = 0
mask[a][mask[a, :, :] >= r] = 1
mask[mask < r] = 0
mask[mask >= r] = 1
else:
# the mask needs to be SxS or AxSxS
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment