Skip to main content

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

PRNG algorithms Period
Quadratic Congruential Generator(QCG) 2^256
Cubic Congruential Generator(CCG) 2^256
Inversive Congruential Generator(ICG) 102*2^256
PCG64_XSL_RR 2^128
PCG64_DXSM 2^128
LCG64_32_ext 2^128
LCG128Mix_XSL_RR 2^128
LCG128Mix_DXSM 2^128
LCG128Mix_MURMUR3 2^128
PhiloxCounter 4*2^(4*64)
ThreeFryCounter 4*2^(4*64)
AESCounter 2^128
ChaChaCounter 2^128
SPECKCounter 2^129
XSM64 2^128
EFIIX64 2^64
SplitMix64 2^64
Ran64 2^64

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

Metadata

Release files for pure-prng 2.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pure-prng 2.9.0
File Size Uploaded
pure_prng-2.9.0.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pure-prng 2.9.0
File Interpreter ABI Platform
pure_prng-2.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 49.2 kB

Release files / pure_prng-2.9.0.tar.gz

Download URL pure_prng-2.9.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74f29084f21e277a28ca718506f37a332c1b12e33619bcbb86d7fc3805e2022e
BLAKE2b-256 checksum
How to use checksums
a3ea9b9094245c80a491eeeb6942d8947a2e573c666b46529f56326a31b6de92
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pure_prng-2.9.0-py3-none-any.whl

Download URL pure_prng-2.9.0-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44c0b3e7c88743fbc92bcb6b616f49f5774707f40e4c9b084b82d4e7c744fb4b
BLAKE2b-256 checksum
How to use checksums
cd446006463c041ec2132e35b25cabfcef900b93545d7cda14adcd39baa20936
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

2.9.0 This release

2 release files

2.8.2

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page