How to use the randomgen.DSFMT 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 / tools / prng-tester.py View on Github external
def configure_stream(
    bit_gen, kwargs=None, jumped=False, streams=8196, entropy=DEFAULT_ENTOPY
):
    bit_generator = bit_gen.__name__
    extra_code = extra_initialization = ""
    if bit_gen == SFC64 and kwargs["k"] == "weyl":
        extra_code = f"""\
base = rg.SFC64(seed_seq)
weyl = base.weyl_increments({streams})
bitgens = [rg.SFC64(seed_seq, k=k) for k in retain]
        """
    elif bit_gen == DSFMT:
        bit_generator = "Wrapper32"
        extra_initialization = DSFMT_WRAPPER
        # return configure_dsfmt(streams, entropy=entropy)
    kwargs = {} if kwargs is None else kwargs
    kwargs_repr = str(kwargs)
    return TEMPLATE.render(
        bit_generator=bit_generator,
        entropy=entropy,
        jumped=jumped,
        streams=streams,
        kwargs=kwargs_repr,
        output=OUTPUT[bit_gen],
        extra_initialization=extra_initialization,
        extra_code=extra_code,
    )
github bashtage / randomgen / tools / test-seed-correlation.py View on Github external
args = [value for value in config.values()]
            for arg_set in itertools.product(*args):
                kwargs = {key: arg for key, arg in zip(config.keys(), arg_set)}
                key = "-".join(
                    [bit_generator]
                    + [f"{key}-{value}" for key, value in kwargs.items()]
                )
                parameters[key] = (bitgen, kwargs)
        else:
            parameters[key] = (bitgen, {})
    for key in parameters:
        extra_initialization = ""
        bitgen, kwargs = parameters[key]
        bit_generator = bitgen.__name__
        kwargs_repr = repr(kwargs)
        if bitgen == DSFMT:
            extra_initialization = DSFMT_WRAPPER
            bit_generator = "Wrapper32"
        streams[key] = TEMPLATE.render(
            streams=num_streams,
            kwargs=kwargs_repr,
            bit_generator=bit_generator,
            output=OUTPUT[bitgen],
            extra_initialization=extra_initialization,
            sequential=sequential,
        )
    return streams
github bashtage / randomgen / tools / configuration.py View on Github external
Xoshiro256,
    Xoshiro512,
    Romu,
]
JUMPABLE = [bg for bg in ALL_BIT_GENS if hasattr(bg, "jumped")]

SPECIALS = {
    ChaCha: {"rounds": [8, 20]},
    JSF: {"seed_size": [1, 3]},
    SFC64: {"k": [1, 3394385948627484371, "weyl"]},
    LCG128Mix: {"output": ["upper"]},
    PCG64: {"variant": ["dxsm", "dxsm-128", "xsl-rr"]},
    Romu: {"variant": ["quad", "trio"]},
}
OUTPUT = defaultdict(lambda: 64)
OUTPUT.update({MT19937: 32, DSFMT: 32})
with open("templates/configuration.jinja") as tmpl:
    TEMPLATE = jinja2.Template(tmpl.read())

DSFMT_WRAPPER = """\

class Wrapper32:
    def __init__(self, seed, **kwargs):
        if isinstance(seed, rg.DSFMT):
            self._bit_gen = seed
        else:
            self._bit_gen = rg.DSFMT(seed)

    def random_raw(self, n=None):
        return self._bit_gen.random_raw(n).astype("u4")

    def jumped(self):
github bashtage / randomgen / doc / source / performance.py View on Github external
RDRAND()
    HAS_RDRND = True
except RuntimeError:
    HAS_RDRND = False

NUMBER = 100
REPEAT = 10
SIZE = 25000
PRNGS = [
    ChaCha8,
    JSF32,
    Philox4x32,
    ThreeFry2x64,
    ThreeFry4x32,
    Philox2x64,
    DSFMT,
    MT64,
    MT19937,
    PCG64,
    PCG64DXSM128,
    PCG64DXSM,
    LXM,
    SFMT,
    AESCounter,
    ChaCha,
    Philox,
    ThreeFry,
    Xoshiro256,
    Xoshiro512,
    JSF,
    Romu,
    RomuTrio,