Skip to main content

Generate professional pseudo-random number package in python.

Project description

Pure_PRNG

PyPI PyPI - Status GitHub Release Date Language grade: Python Codacy Badge PyPI - Downloads PyPI - Python Version PyPI - License

Generate professional pseudo-random number package in python.

Only the pseudo-random number algorithm with good statistical properties is implemented.

There are "methods" that specify the period of a multi-precision pseudo-random sequence.

Realized pseudo-random number generation algorithm

Quadratic Congruential Generator

Cubic Congruential Generator

Inversive Congruential Generator

PCG64_XSL_RR; PCG64_DXSM

LCG64_32_ext

LCG128Mix_XSL_RR; LCG128Mix_DXSM; LCG128Mix_MURMUR3

XSM64

EFIIX64

SplitMix64

Ran64

PhiloxCounter

ThreeFryCounter

AESCounter

ChaChaCounter

SPECKCounter

SquaresCounter

Please inform me if any PRNG fails to pass the new statistical test.

Installation

Installation can be done through pip. You must have python version >= 3.8

pip install pure-prng

Usage

The statement to import the package:

from pure_prng_package import pure_prng

Example:

>>> seed = 170141183460469231731687303715884105727
>>> period = 115792089237316195423570985008687907853269984665640564039457584007913129639747

>>> prng_instance = pure_prng(seed)
>>> source_random_number = prng_instance.source_random_number()
>>> next(source_random_number)
65852230656997158461166665751696465914198450243194923777324019418213544382100

>>> prng_instance = pure_prng(seed, new_prng_period = 2 ** 512)
>>> source_random_number = prng_instance.source_random_number()
>>> next(source_random_number)
8375486648769878807557228126183349922765245383564825377649864304632902242469125910865615742661048315918259479944116325466004411700005484642554244082978452

>>> prng_instance = pure_prng(seed)
>>> rand_bits = prng_instance.rand_bits(512)
>>> next(rand_bits)
mpz(6144768950704661248519702670268583753928668607451020183407159490385670202458730311510261255705698403097105657582435836672179668357656056427608305574891156)
>>> rand_bits = prng_instance.rand_bits(512, period)
>>> next(rand_bits)
mpz(2954964798889411590155032615694646383408546750268072607273800792672971321854983100133610686738061114434885994588970398525439724215184541467422573311905001)

>>> prng_instance = pure_prng(seed)
>>> rand_float = prng_instance.rand_float(100)
>>> next(rand_float)
mpfr('0.56576176351048513846261940831522',100)

>>> prng_instance = pure_prng(seed)
>>> rand_int = prng_instance.rand_int(100, 1)
>>> next(rand_int)
mpz(21)

>>> prng_instance = pure_prng(seed)
>>> get_randint_set = prng_instance.get_randint_set(100, 1, 6)
>>> next(get_randint_set)
{mpz(34), mpz(99), mpz(37), mpz(45), mpz(19), mpz(21)}

>>> prng_instance = pure_prng(seed)
>>> rand_with_period = prng_instance.rand_with_period(period)
>>> next(rand_with_period)
mpz(65852230656997158461166665751696465914198450243194923777324019418213544381986)
>>> rand_with_period = prng_instance.rand_with_period(period, 'raw_binary_number')
>>> next(rand_with_period)
mpz(53067260390396280968027884646874354062063398901623645439544105836818444733296)

##Future work

The following algorithm is intended to be implemented:

NLFSR

Cellular automate period pseudo random

GPU Philox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pure_prng-2.6.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

pure_prng-2.6.1-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file pure_prng-2.6.1.tar.gz.

File metadata

  • Download URL: pure_prng-2.6.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pure_prng-2.6.1.tar.gz
Algorithm Hash digest
SHA256 f0173a6f3a530052571e5cc4e87adfd557efbef6c667215c28cf7df1991d4d19
MD5 b88336a2c0daa3a8d5af38e6bed7c1ac
BLAKE2b-256 e31865cf078c9879d4469d034080ec979c4b6c2fd22a01a92435752eae421900

See more details on using hashes here.

File details

Details for the file pure_prng-2.6.1-py3-none-any.whl.

File metadata

  • Download URL: pure_prng-2.6.1-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pure_prng-2.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d936a45a8bf551d825b7ce1e4bde1b6318ce18d2cbdf7f72156cff1e35fe1650
MD5 d8b096bb372254fa08d1a8da844c478e
BLAKE2b-256 6c0d7cf83254b5f97c8a7499d9132e0b2d64cea9d3629977a5b2b6e3be5cf984

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page