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_typeis a valid choice inuncertainty_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]))]
- Args:
- 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 is100. - seed (int, optional): Seed value for the random number generator. Default is
None.
- Returns:
- A class instance
-
__init__(params, maximum_iterations=50, seed=None, **kwargs)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
get_positions()¶ Construct dictionary of where each distribution starts and stops in the sorted parameter array
-
next()¶ Generate a new vector of random numbers
-
verify_params()¶ Verify that all uncertainty types are allowed, and parameter validate using distribution class methods
- Each unique