Skip to content

Commit

Permalink
MAINT: remove call to np.random
Browse files Browse the repository at this point in the history
  • Loading branch information
ColmTalbot committed Jan 16, 2024
1 parent d2eca13 commit 7276a60
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions py/dynesty/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from .results import Results, print_fn
from .bounding import UnitCube
from .sampling import sample_unif, SamplerArgument
from .utils import (get_seed_sequence, get_print_func, progress_integration,
from .utils import (get_random_generator, get_seed_sequence,
get_print_func, progress_integration,
IteratorResult, RunRecord, get_neff_from_logwt,
compute_integrals, DelayTimer, _LOWL_VAL)

Expand Down Expand Up @@ -430,10 +431,11 @@ def _distance_insertion_index(self, start, point):
if distance == 0:
log_ratio = np.inf
else:
other = self.live_u[np.random.choice(len(self.live_u))]
rstate = get_random_generator(self.rstate)
other = self.live_u[rstate.choice(len(self.live_u))]
other_distance = np.linalg.norm((other - start) / norms)
while other_distance == 0:
other = self.live_u[np.random.choice(len(self.live_u))]
other = self.live_u[rstate.choice(len(self.live_u))]
other_distance = np.linalg.norm((other - start) / norms)
alt_distance = np.linalg.norm((point - other) / norms)
log_ratio = self.ndim * (np.log(other_distance / distance) + np.log(other_distance / alt_distance)) / 2
Expand Down

0 comments on commit 7276a60

Please sign in to comment.