Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supakeen/simba
PRNGs for Nim.
https://github.com/supakeen/simba
nim prng
Last synced: 7 days ago
JSON representation
PRNGs for Nim.
- Host: GitHub
- URL: https://github.com/supakeen/simba
- Owner: supakeen
- License: mit
- Created: 2020-10-04T10:32:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T14:08:55.000Z (over 4 years ago)
- Last Synced: 2025-01-19T21:48:19.318Z (13 days ago)
- Topics: nim, prng
- Language: Nim
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simba
**Note**: this project is still in active development and not all implementations
have corresponding testcase and as such have not been proven to be correct,
please hold off on using this until these tests are added and this notice is
removed.This project provides implementations of pseudorandom number generators in pure
Nim. It can be used to generate the same sequences as other PRNGs provided you
know the parameters they use.All PRNGs implemented in `simba` are *not* cryptographically secure. If you
don't know if you need a CSPRNG or a PRNG you should opt for the first one and
skip this library.## Usage
`simba` provides a high level API that works across all provided PRNGs. Take
care that this high level API might implement these functions differently from
other implementations even if the underlying PRNG yields the same values.```nim
import simba
import simba/lcg
import simba/lfsrlet
prng0 = newRANDU()
prng1 = newXorShift64s()echo prng0.randBits(8)
echo prng1.randBits(8)
```If you need to do other conversions you can use the PRNGs directly, they will
yield next values in the correct width.```nim
import simba/mersennelet prng = newMT19937()
echo next(prng)
echo next(prng)
```## PRNGs
`simba` currently implements the following types and specific PRNGs.
### Linear Congruential Generators
- [x] RANDU
- [x] Numerical Recipes
- [x] Visual Basic 6 and below.
- [x] Java's Math.random
- [x] CarbonLib
- [x] C++11
- [x] Turbo Pascal
- [x] MMIX
- [x] Musl### Linear Feedback Shift Registers
- [x] xorshift32
- [x] xorshift64
- [ ] xorshift128
- [ ] xorwow
- [x] xorshift64s
- [ ] xorshift1024s
- [ ] xoshiro256ss
- [ ] xoshiro256p
- [ ] splitmix64### Mersenne
- [ ] MT19337
- [ ] MT19337-64## Bindings
Work has started on providing Python bindings for `simba`, you can find them in
the [sarafi](https://github.com/supakeen/sarafi) project.