create_rng#

pharmpy.modeling.create_rng(seed=None)[source]#

Create a new random number generator

Pharmpy functions that use random sampling take a random number generator or seed as input. This function can be used to create a default new random number generator.

Parameters:

seed (int or rng) – Seed for the random number generator or None (default) for a randomized seed. If seed is generator it will be passed through.

Returns:

Generator – Initialized numpy random number generator object

Examples

>>> from pharmpy.modeling import create_rng
>>> rng = create_rng(23)
>>> rng.standard_normal()
0.5532605888887387