applied-econometrics-2024/scripts/util/__init__.py

25 lines
490 B
Python
Raw Normal View History

2024-12-29 18:42:48 +01:00
import os
import numpy as np
def group_seed():
bd_env_var = os.getenv("BIRTHDAYS")
# If no birthdays are set, complain and exit
if not bd_env_var:
print("Environment variable BIRTHDAYS is missing")
exit(-1)
# convert birthdays to ints
birthdays = [int(bd) for bd in bd_env_var.split(",")]
# multiply them to get the group seed
seed = 1
for bd in birthdays:
seed *= bd
return seed
rng = np.random.default_rng(group_seed())