How to use the randomgen.generator.RandomGenerator function in randomgen

To help you get started, we’ve selected a few randomgen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bashtage / randomgen / randomgen / legacy / legacy.py View on Github external
1.6465621229906502

    The equivalent commands from NumPy produce identical output.

    >>> from numpy.random import RandomState
    >>> rs = RandomState(12345)
    >>> x = rs.standard_normal(10)
    >>> rs.shuffle(x)
    >>> x[0]
    0.09290787674371767
    >>> rs.standard_exponential()
    1.6465621229906502
    """

    __atttributes = sorted(set(dir(_LegacyGenerator) +
                               dir(RandomGenerator))
                           .difference(_HIDDEN_ATTRIBUTES))

    def __init__(self, brng=None):
        if brng is None:
            brng = MT19937()
        super(LegacyGenerator, self).__init__(brng)
        self.__legacy = _LegacyGenerator(brng)

    def __getattribute__(self, name):
        if name in _HIDDEN_ATTRIBUTES:
            raise AttributeError('No attribute {0}'.format(name))
        if name in _LEGACY_ATTRIBUTES:
            return self.__legacy.__getattribute__(name)
        return object.__getattribute__(self, name)

    def __dir__(self):
github bashtage / randomgen / randomgen / legacy / legacy.py View on Github external
def __getattribute__(self, name):
        if name in _LEGACY_ATTRIBUTES:
            return object.__getattribute__(_LegacyGenerator, name)
        return object.__getattribute__(RandomGenerator, name)
github bashtage / randomgen / randomgen / legacy / legacy.py View on Github external
return meta(name, bases, d)

        @classmethod
        def __prepare__(cls, name, this_bases):
            return meta.__prepare__(name, bases)
    return type.__new__(metaclass, 'temporary_class', (), {})


class LegacyGeneratorType(type):
    def __getattribute__(self, name):
        if name in _LEGACY_ATTRIBUTES:
            return object.__getattribute__(_LegacyGenerator, name)
        return object.__getattribute__(RandomGenerator, name)


class LegacyGenerator(with_metaclass(LegacyGeneratorType, RandomGenerator)):
    """
    LegacyGenerator(brng=None)

    Container providing legacy generators.

    ``LegacyGenerator`` exposes a number of methods for generating random
    numbers for a set of distributions where the method used to produce random
    samples has changed. Three core generators have changed: normal,
    exponential and gamma. These have been replaced by faster Ziggurat-based
    methods in ``RadnomGenerator``. ``LegacyGenerator`` retains the slower
    methods to produce samples from these distributions as well as from
    distributions that depend on these such as the Chi-square, power or
    Weibull.

    **No Compatibility Guarantee**