{"id":15362078,"url":"https://github.com/bashtage/ng-numpy-randomstate","last_synced_at":"2025-04-15T07:30:39.532Z","repository":{"id":57459906,"uuid":"47585172","full_name":"bashtage/ng-numpy-randomstate","owner":"bashtage","description":"Numpy-compatible random number generator that supports multiple core psuedo RNGs and explicitly parallel generation.","archived":false,"fork":false,"pushed_at":"2019-03-02T20:49:10.000Z","size":18618,"stargazers_count":45,"open_issues_count":1,"forks_count":14,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-28T18:21:17.871Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashtage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T23:13:21.000Z","updated_at":"2024-08-15T18:25:21.000Z","dependencies_parsed_at":"2022-08-30T17:10:26.782Z","dependency_job_id":null,"html_url":"https://github.com/bashtage/ng-numpy-randomstate","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Fng-numpy-randomstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Fng-numpy-randomstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Fng-numpy-randomstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashtage%2Fng-numpy-randomstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashtage","download_url":"https://codeload.github.com/bashtage/ng-numpy-randomstate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248614089,"owners_count":21133658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T12:58:26.984Z","updated_at":"2025-04-15T07:30:38.830Z","avatar_url":"https://github.com/bashtage.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Future development in [randomgen](https://github.com/bashtage/randomgen)\n\n**End-of-life notification**\n\nThis library was designed to bring alternative generators to the NumPy \ninfrastructure. It as been successful in advancing the conversation \nfor a future implementation of a new random number API in NumPy which \nwill allow new algorithms and/or generators. The next step\nin this process is to separate the basic (or core RNG) from the \nfunctions that transform random bits into useful random numbers.\nThis has been implemented in a successor project  **randomgen** \navailable on [GitHub](https://github.com/bashtage/randomgen) or\n[PyPi](https://pypi.org/project/randomgen/).\n\n[randomgen](https://github.com/bashtage/randomgen) has a slightly different API, so please see the  [randomgen documentation](https://bashtage.github.io/randomgen).\n\n-----------------------------------------------------------------------\n\n# randomstate\n\n[![Travis Build Status](https://travis-ci.org/bashtage/ng-numpy-randomstate.svg?branch=master)](https://travis-ci.org/bashtage/ng-numpy-randomstate) \n[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/odc5c4ukhru5xicl/branch/master?svg=true)](https://ci.appveyor.com/project/bashtage/ng-numpy-randomstate/branch/master)\n[![PyPI version](https://badge.fury.io/py/randomstate.svg)](https://badge.fury.io/py/randomstate)\n\n## Introduction\n\nThis is a library and generic interface for alternative random \ngenerators in Python and NumPy. \n\n## Features\n\n* Immediate drop in replacement for NumPy's RandomState\n\n```python\n# import numpy.random as rnd\nimport randomstate as rnd\nx = rnd.standard_normal(100)\ny = rnd.random_sample(100)\nz = rnd.randn(10,10)\n```\n\n* Default random generator is identical to NumPy's RandomState (i.e., \nsame seed, same random numbers).\n* Support for random number generators that support independent streams \nand jumping ahead so that sub-streams can be generated\n* Faster random number generation, especially for normal, standard\n  exponential and standard gamma using the Ziggurat method\n\n```python\nimport randomstate as rnd\nw = rnd.standard_normal(10000, method='zig')\nx = rnd.standard_exponential(10000, method='zig')\ny = rnd.standard_gamma(5.5, 10000, method='zig')\n```\n\n* Support for 32-bit floating randoms for core generators. \n  Currently supported:\n\n    * Uniforms (`random_sample`)\n    * Exponentials (`standard_exponential`, both Inverse CDF and Ziggurat)\n    * Normals (`standard_normal`, both Box-Muller and Ziggurat)\n    * Standard Gammas (via `standard_gamma`, both Inverse CDF and Ziggurat)\n  \n  **WARNING**: The 32-bit generators are **experimental** and subject \n  to change.\n  \n  **Note**: There are _no_ plans to extend the alternative precision \n  generation to all random number types.\n\n* Support for filling existing arrays using `out` keyword argument. Currently\n  supported in (both 32- and 64-bit outputs)\n\n    * Uniforms (`random_sample`)\n    * Exponentials (`standard_exponential`)\n    * Normals (`standard_normal`)\n    * Standard Gammas (via `standard_gamma`)\n\n## Included Pseudo Random Number Generators\n\nThis modules includes a number of alternative random \nnumber generators in addition to the MT19937 that is included in NumPy. \nThe RNGs include:\n\n* [MT19937](https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/),\n the NumPy rng\n* [dSFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/) a \n  SSE2-aware version of the MT19937 generator that is especially fast at \n  generating doubles\n* [SFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/) a\n  SSE2-aware version of the MT19937 generator that is optimized for\n  integer values\n* [xorshift128+](http://xorshift.di.unimi.it/),\n  [xoroshiro128+](http://xoroshiro.di.unimi.it/) and\n  [xorshift1024*](http://xorshift.di.unimi.it/)\n* [PCG32](http://www.pcg-random.org/) and \n  [PCG64](http:w//www.pcg-random.org/)\n* [MRG32K3A](http://simul.iro.umontreal.ca/rng)\n* A multiplicative lagged fibonacci generator (LFG(63, 1279, 861, *))\n\n## Differences from `numpy.random.RandomState`\n\n### New Features\n* `standard_normal`, `normal`, `randn` and `multivariate_normal` all \n  support an additional `method` keyword argument which can be `bm` or\n  `zig` where `bm` corresponds to the current method using the Box-Muller\n  transformation and `zig` uses the much faster (100%+) Ziggurat method.\n* `standard_exponential` and `standard_gamma` both support an additional\n  `method` keyword argument which can be `inv` or\n  `zig` where `inv` corresponds to the current method using the inverse\n  CDF and `zig` uses the much faster (100%+) Ziggurat method.\n* Core random number generators can produce either single precision\n  (`np.float32`) or double precision (`np.float64`, the default) using\n  an the optional keyword argument `dtype`\n* Core random number generators can fill existing arrays using the\n  `out` keyword argument\n\n\n### New Functions\n\n* `random_entropy` - Read from the system entropy provider, which is \ncommonly used in cryptographic applications\n* `random_raw` - Direct access to the values produced by the underlying \nPRNG. The range of the values returned depends on the specifics of the \nPRNG implementation.\n* `random_uintegers` - unsigned integers, either 32- (`[0, 2**32-1]`)\nor 64-bit (`[0, 2**64-1]`)\n* `jump` - Jumps RNGs that support it.  `jump` moves the state a great \ndistance. _Only available if supported by the RNG._\n* `advance` - Advanced the core RNG 'as-if' a number of draws were made, \nwithout actually drawing the numbers. _Only available if supported by \nthe RNG._\n\n## Status\n\n* Complete drop-in replacement for `numpy.random.RandomState`. The \n`mt19937` generator is identical to `numpy.random.RandomState`, and \nwill produce an identical sequence of random numbers for a given seed.   \n* Builds and passes all tests on:\n  * Linux 32/64 bit, Python 2.7, 3.4, 3.5, 3.6 (probably works on 2.6 and 3.3)\n  * PC-BSD (FreeBSD) 64-bit, Python 2.7\n  * OSX 64-bit, Python 2.7\n  * Windows 32/64 bit (only tested on Python 2.7, 3.5 and 3.6, but\n    should work on 3.3/3.4)\n\n## Version\nThe version matched the latest version of NumPy where \n`randomstate.prng.mt19937` passes all NumPy test.\n\n## Documentation\n\nAn occasionally updated build of the documentation is available on\n[my github pages](http://bashtage.github.io/ng-numpy-randomstate/).\n\n## Plans\nThis module is essentially complete.  There are a few rough edges that \nneed to be smoothed.\n  \n  * Stream support for MLFG\n  * Creation of additional streams from a RandomState where supported \n  (i.e. a `next_stream()` method)\n  \n## Requirements\nBuilding requires:\n\n  * Python (2.7, 3.4, 3.5, 3.6)\n  * NumPy (1.9, 1.10, 1.11, 1.12)\n  * Cython (0.22, **not** 0.23, 0.24, 0.25)\n  * tempita (0.5+), if not provided by Cython\n \nTesting requires pytest (3.0+).\n\n**Note:** it might work with other versions but only tested with these \nversions. \n\n## Development and Testing\n\nAll development has been on 64-bit Linux, and it is regularly tested on \nTravis-CI. The library is occasionally tested on Linux 32-bit,  \nOSX 10.10, PC-BSD 10.2 (should also work on Free BSD) and Windows \n(Python 2.7/3.5, both 32 and 64-bit).\n\nBasic tests are in place for all RNGs. The MT19937 is tested against \nNumPy's implementation for identical results. It also passes NumPy's \ntest suite.\n\n## Installing\n\n```bash\npython setup.py install\n```\n\n### SSE2\n`dSFTM` makes use of SSE2 by default.  If you have a very old computer \nor are building on non-x86, you can install using:\n\n```bash\npython setup.py install --no-sse2\n```\n\n### Windows\nEither use a binary installer, or if building from scratch, use \nPython 3.5 with Visual Studio 2015 Community Edition. It can also be \nbuild using Microsoft Visual C++ Compiler for Python 2.7 and Python 2.7, \nalthough some modifications may be needed to `distutils` to find the \ncompiler.\n\n## Using\n\nThe separate generators are importable from `randomstate.prng`.\n\n```python\nimport randomstate\nrs = randomstate.prng.xorshift128.RandomState()\nrs.random_sample(100)\n\nrs = randomstate.prng.pcg64.RandomState()\nrs.random_sample(100)\n\n# Identical to NumPy\nrs = randomstate.prng.mt19937.RandomState()\nrs.random_sample(100)\n```\n\nLike NumPy, `randomstate` also exposes a single instance of the \n`mt19937` generator directly at the module level so that commands like\n\n```python\nimport randomstate\nrandomstate.standard_normal()\nrandomstate.exponential(1.0, 1.0, size=10)\n```\n\nwill work.\n\n## License\nStandard NCSA, plus sub licenses for components.\n\n## Performance\nPerformance is promising, and even the mt19937 seems to be faster than \nNumPy's mt19937. \n\n```\nSpeed-up relative to NumPy (Uniform Doubles)\n************************************************************\nrandomstate.prng-dsfmt-random_sample               313.5%\nrandomstate.prng-mlfg_1279_861-random_sample       459.4%\nrandomstate.prng-mrg32k3a-random_sample            -57.6%\nrandomstate.prng-mt19937-random_sample              72.5%\nrandomstate.prng-pcg32-random_sample               232.8%\nrandomstate.prng-pcg64-random_sample               330.6%\nrandomstate.prng-xoroshiro128plus-random_sample    609.9%\nrandomstate.prng-xorshift1024-random_sample        348.8%\nrandomstate.prng-xorshift128-random_sample         489.7%\n\nSpeed-up relative to NumPy (Normals using Box-Muller)\n************************************************************\nrandomstate.prng-dsfmt-standard_normal                26.8%\nrandomstate.prng-mlfg_1279_861-standard_normal        30.9%\nrandomstate.prng-mrg32k3a-standard_normal            -14.8%\nrandomstate.prng-mt19937-standard_normal              17.7%\nrandomstate.prng-pcg32-standard_normal                24.5%\nrandomstate.prng-pcg64-standard_normal                26.2%\nrandomstate.prng-xoroshiro128plus-standard_normal     31.4%\nrandomstate.prng-xorshift1024-standard_normal         27.4%\nrandomstate.prng-xorshift128-standard_normal          30.3%\n\nSpeed-up relative to NumPy (Normals using Ziggurat)\n************************************************************\nrandomstate.prng-dsfmt-standard_normal               491.7%\nrandomstate.prng-mlfg_1279_861-standard_normal       439.6%\nrandomstate.prng-mrg32k3a-standard_normal            101.2%\nrandomstate.prng-mt19937-standard_normal             354.4%\nrandomstate.prng-pcg32-standard_normal               531.0%\nrandomstate.prng-pcg64-standard_normal               517.9%\nrandomstate.prng-xoroshiro128plus-standard_normal    674.0%\nrandomstate.prng-xorshift1024-standard_normal        486.7%\nrandomstate.prng-xorshift128-standard_normal         617.0%\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashtage%2Fng-numpy-randomstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashtage%2Fng-numpy-randomstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashtage%2Fng-numpy-randomstate/lists"}