Skip to content

Commit

Permalink
Merge pull request #113 from perib/dev
Browse files Browse the repository at this point in the history
fixed recursive search space probabilities
  • Loading branch information
perib authored Dec 5, 2023
2 parents cf5d1af + a904acf commit 1fc2a76
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,10 @@ def random_weighted_sort(l,weights, rng_=None):
sorted_l = []
indeces = {i: weights[i] for i in range(len(l))}
while len(indeces) > 0:
next_item = rng.choice(list(indeces.keys()), p=list(indeces.values()))
keys = list(indeces.keys())
p = np.array([indeces[k] for k in keys])
p = p / p.sum()
next_item = rng.choice(list(indeces.keys()), p=p)
indeces.pop(next_item)
sorted_l.append(l[next_item])

Expand Down

0 comments on commit 1fc2a76

Please sign in to comment.