How to use the randomgen.ThreeFry 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 MartinThoma / algorithms / Python / random / generate_number_image.py View on Github external
if prng not in allowed_prngs:
        raise ValueError(f"prng={prng} is not in {allowed_prngs}")
    arr = np.zeros((size, size))
    for i in range(size):
        if prng == "python":
            random.seed(i)
        elif prng == "numpy":
            np.random.seed(i)
        elif prng == "java":
            rnd = javarandom.Random(i)
        elif prng == "Xoroshiro128":
            rnd = RandomGenerator(Xoroshiro128())
        elif prng == "Xorshift1024":
            rnd = RandomGenerator(Xorshift1024())
        elif prng == "ThreeFry":
            rnd = RandomGenerator(ThreeFry())
        elif prng == "MT19937":
            rnd = Generator(MT19937())
        elif prng == "Philox":
            rnd = Generator(Philox())
        elif prng == "SFC64":
            rnd = Generator(SFC64())

        for j in range(size):
            if prng == "python":
                random_number = random.random()
            elif prng == "numpy":
                random_number = np.random.random()
            elif prng == "java":
                random_number = rnd.nextDouble()
            elif prng in ["Xoroshiro128", "Xorshift1024", "ThreeFry"]:
                random_number = rnd.random_sample()
github bashtage / randomgen / doc / source / performance.py View on Github external
def __init__(self, *args, **kwargs):
        if "number" in kwargs:
            del kwargs["number"]
        super().__init__(*args, number=2, **kwargs)


class RomuTrio(Romu):
    canonical_repr = 'Romu(variant="trio")'

    def __init__(self, *args, **kwargs):
        if "variant" in kwargs:
            del kwargs["variant"]
        super().__init__(*args, variant="trio")


class ThreeFry4x32(ThreeFry):
    canonical_repr = "ThreeFry(n=4, w=32)"

    def __init__(self, *args, **kwargs):
        if "width" in kwargs:
            del kwargs["width"]
        super().__init__(*args, width=32, **kwargs)


class ThreeFry2x64(ThreeFry):
    canonical_repr = "ThreeFry(n=2, w=64)"

    def __init__(self, *args, **kwargs):
        if "number" in kwargs:
            del kwargs["number"]
        super().__init__(*args, number=2, **kwargs)
github bashtage / randomgen / doc / source / performance.py View on Github external
def __init__(self, *args, **kwargs):
        if "variant" in kwargs:
            del kwargs["variant"]
        super().__init__(*args, variant="trio")


class ThreeFry4x32(ThreeFry):
    canonical_repr = "ThreeFry(n=4, w=32)"

    def __init__(self, *args, **kwargs):
        if "width" in kwargs:
            del kwargs["width"]
        super().__init__(*args, width=32, **kwargs)


class ThreeFry2x64(ThreeFry):
    canonical_repr = "ThreeFry(n=2, w=64)"

    def __init__(self, *args, **kwargs):
        if "number" in kwargs:
            del kwargs["number"]
        super().__init__(*args, number=2, **kwargs)


class PCG64DXSM128(PCG64):
    canonical_repr = 'PCG64(variant="dxsm-128")'

    def __init__(self, *args, **kwargs):
        if "variant" in kwargs:
            del kwargs["variant"]
        super().__init__(*args, variant="dxsm-128", **kwargs)
github bashtage / randomgen / tools / configuration.py View on Github external
ALL_BIT_GENS = [
    AESCounter,
    ChaCha,
    DSFMT,
    EFIIX64,
    HC128,
    JSF,
    LXM,
    PCG64,
    LCG128Mix,
    MT19937,
    Philox,
    SFC64,
    SFMT,
    SPECK128,
    ThreeFry,
    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})
github bashtage / randomgen / doc / source / performance.py View on Github external
Philox4x32,
    ThreeFry2x64,
    ThreeFry4x32,
    Philox2x64,
    DSFMT,
    MT64,
    MT19937,
    PCG64,
    PCG64DXSM128,
    PCG64DXSM,
    LXM,
    SFMT,
    AESCounter,
    ChaCha,
    Philox,
    ThreeFry,
    Xoshiro256,
    Xoshiro512,
    JSF,
    Romu,
    RomuTrio,
    HC128,
    SPECK128,
    SFC64,
    EFIIX64,
]

if HAS_RDRND:
    PRNGS.append(RDRAND)


funcs = OrderedDict()
github bashtage / randomgen / tools / practrand-driver.py View on Github external
import sys

import numpy as np

import randomgen as rg

BUFFER_SIZE = 256 * 2 ** 20

DESCRIPTION = """
A driver that simplifies testing bit generators using PractRand.
"""

CONFIG = {
    rg.PCG32: {"output": 32, "seed": 64, "seed_size": 64},
    rg.PCG64: {"output": 64, "seed": 128, "seed_size": 128},
    rg.ThreeFry: {"output": 64, "seed": 256, "seed_size": 64},
    rg.Xoshiro256: {"output": 64, "seed": 256, "seed_size": 64},
    rg.Philox: {"output": 64, "seed": 256, "seed_size": 64},
    rg.SFMT: {"output": 64, "seed": 128, "seed_size": 32},
    rg.LXM: {"output": 64, "seed": 128, "seed_size": 32},
    rg.SFC64: {"output": 64, "seed": 128, "seed_size": 32},
    rg.AESCounter: {"output": 64, "seed": 128, "seed_size": 32},
}


def reorder_bytes(a):
    dtype = a.dtype
    assert dtype in (np.uint32, np.uint64)
    cols = 8 if dtype == np.uint64 else 4
    a = a.view(np.uint8).reshape((-1, cols))
    return a.ravel("F").view(dtype)