I would like to be able to pass a random number generator to a class in Python. A class is a simulation study, in which a specific set of variables is initialized with the draw of the beta-distribution, which can be created with the help random.betavariate(2,2), but I would like to allow users to connect to the future function of generating random numbers are another type, for example random.uniform(0,1).
When I try to initialize it like this ...
class simulation:
def __init__(self,rng):
self._rng = rng
s = simulation(random.betavariate(2,2))
... the error is that instead of passing the function itself, I only pass a freshly generated random number.
>>> s._rng
0.5013004813544717
>>> s._rng
0.5013004813544717
: , , ? , , (re) random.