Monte Carlo random number generator

class stats_arrays.MCRandomNumberGenerator(params, maximum_iterations=50, seed=None, **kwargs)

A Monte Carlo random number generator that operates on a Heterogeneous parameter array.

Upon instantiation, the class checks that:

  • Each unique uncertainty_type is a valid choice in uncertainty_choices
  • That the parameter array for each uncertainty type validates

The returned class instance can be called directly with next, or can be used as an iterator:

>>> from stats_arrays import MCRandomNumberGenerator, UncertaintyBase
>>> params = UncertaintyBase.from_dicts(
...     {'loc': 5, 'minimum': 3, 'maximum': 10, 'uncertainty_type': 5},
...     {'loc': 1, 'scale': 0.7, 'uncertainty_type': 3}
...     )
>>> mcrng = MCRandomNumberGenerator(params)
>>> zip(range(2), mcrng)
[(0, array([ 1.35034874,  5.2705415 ])),
 (1, array([ 5.2705415 ,  1.35034874]))]
  • params (array): The Heterogeneous parameter array
  • maximum_iterations (int, optional): The number of times to draw samples that fit within the given bounds, if any, before raising stats_arrays.MaximumIterationsError. Default is 100.
  • seed (int, optional): Seed value for the random number generator. Default is None.
A class instance
__init__(params, maximum_iterations=50, seed=None, **kwargs)

Construct dictionary of where each distribution starts and stops in the sorted parameter array


Generate a new vector of random numbers


Verify that all uncertainty types are allowed, and parameter validate using distribution class methods