Skip to content

Commit

Permalink
Add seeds to Uniform() still missing them
Browse files Browse the repository at this point in the history
  • Loading branch information
amyheather committed May 24, 2024
1 parent a12ccc5 commit 4c86332
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions reproduction/sim/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, minimum, maximum, random_seed=None):
A random seed to reproduce samples. If set to none then a unique
sample is created.
'''
self.rand = np.random.default_rng(seed=random_seed)
self.rng = np.random.default_rng(seed=random_seed)
self.maximum = maximum
self.minimum = minimum

Expand All @@ -106,7 +106,7 @@ def sample(self, size=None):
uniform distributed variates.
'''

return self.rand.uniform(
return self.rng.uniform(
low=self.minimum, high=self.maximum, size=size)


Expand All @@ -123,10 +123,10 @@ class Scenario:
'''

# Generate N_STREAMS high quality child seeds
DEFAULT_RNG_SET = 42
N_STREAMS = 20
seed_sequence = np.random.SeedSequence(DEFAULT_RNG_SET)
seeds = seed_sequence.spawn(N_STREAMS)
default_seed = 42
n_streams = 20
seed_sequence = np.random.SeedSequence(default_seed)
seeds = seed_sequence.spawn(n_streams)

run_length: float = 200

Expand Down Expand Up @@ -155,13 +155,13 @@ class Scenario:
mortality: float = 0.15

# Mortality random number
mortality_rand = Uniform(0.0, 1.0)
mortality_rand = Uniform(0.0, 1.0, random_seed=seeds[5])

# Add random positives at start; applies to negative patients
random_positive_rate_at_start: float = 0.0

# Restrict the maximum proportion of people who can be infected
will_be_infected_rand = Uniform(0.0, 1.0)
# Restrict the maximum proportion of people who can be infected
will_be_infected_rand = Uniform(0.0, 1.0, random_seed=seeds[6])

# Strategies ---------------------------------

Expand Down

0 comments on commit 4c86332

Please sign in to comment.