Skip to content

Commit

Permalink
better use of random seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Feb 7, 2024
1 parent 58e29b8 commit a1936a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sharkfin/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,13 @@ def __init__(
fm_args=fm_args,
)

self.rng = rng if rng is not None else np.random.default_rng()

if seed:
self.seed = seed
elif hasattr(rng, "seed"):
self.seed = rng.seed

self.rng = rng if rng is not None else np.random.default_rng(seed)

# TODO: Make this more variable.
if a is not None:
self.attention_rate = a
Expand Down
6 changes: 4 additions & 2 deletions simulate/run_any_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ def env_param(name, default):
parameter_dict["aNrmInitMean"] = pop_aNrmInitMean
else:
raise Exception(f"No valid population named! Got {population_name}. Panic!")

bigseed = rng.integers(0, 2**31 - 1)

if args.simulation == "Attention":
data, sim_stats, history, class_stats = run_attention_simulation(
Expand All @@ -398,7 +400,7 @@ def env_param(name, default):
mba=mba,
rng=rng,
pad=pad,
seed=seed,
seed=bigseed,
)
elif args.simulation == "Calibration":
data, sim_stats, history, class_stats = run_chum_simulation(
Expand All @@ -412,7 +414,7 @@ def env_param(name, default):
buy=buysize,
sell=sellsize,
pad=pad,
seed=seed,
seed=bigseed,
)
else:
print(
Expand Down

0 comments on commit a1936a0

Please sign in to comment.