https://github.com/csoroiu/untwist
Collection of reversible PRNG's (Python, FreePascal, TurboPascal, .NET)
https://github.com/csoroiu/untwist
lcg linear-congruential-generator mersenne-twister prng pseudo-random random random-number-generator rng
Last synced: 5 months ago
JSON representation
Collection of reversible PRNG's (Python, FreePascal, TurboPascal, .NET)
- Host: GitHub
- URL: https://github.com/csoroiu/untwist
- Owner: csoroiu
- License: apache-2.0
- Created: 2017-07-30T06:35:51.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-01-14T21:16:48.000Z (over 2 years ago)
- Last Synced: 2024-01-15T01:17:29.105Z (over 2 years ago)
- Topics: lcg, linear-congruential-generator, mersenne-twister, prng, pseudo-random, random, random-number-generator, rng
- Language: Java
- Size: 448 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# untwist
[![Maven Central][maven-tasks-svg]][maven-tasks-link]
[![Javadoc][javadoc-svg]][javadoc-link]
[![Build Status][build-status-svg]][build-status-link]
[![License][license-svg]][license-link]
**untwist** is a collection of PRNG's from **.NET**, **Free Pascal**, **Turbo Pascal**, **Python**.
**Python** and **Free Pascal** use the **Mersenne Twister** as a randomization source.
**Turbo Pascal** and **Java** are using a **linear congruential generator (LCG)**.
**.NET** is using a modified version of Donald E. Knuth's **subtractive random number generator** algorithm.
**Given the same input (seed) they generate the same values as the ones in the respective languages.**
Also, besides their normal use, I have added functions to go backward. The **Mersenne Twister**
and **LCG**'s are reversible.
Also, **LCG**'s and **subtractive generators** are trivial to revert.
I got the idea of reversing the generators from several places, after I had to break the seed of some generator, in order to reduce the size of the archived dataset.
## Disclaimer
*There are some cases in which the reverse does not work as expected. Try not to mix next and prev versions of the methods as you might run into strange situations.*
*Some of the situations are captured by unit tests which are currently marked as ignored.*
*Most of the time things go well.*
***Nevertheless, use it at your own risk. This library comes with no guarantees.***
## Usage
#### Maven dependency
```xml
ro.derbederos
untwist
0.5
```
#### Gradle dependency
```groovy
compile 'ro.derbederos:untwist:0.5'
```
Enjoy using them!
[build-status-svg]: https://travis-ci.org/csoroiu/untwist.svg?branch=master
[build-status-link]: https://travis-ci.org/csoroiu/untwist
[javadoc-svg]: http://javadoc.io/badge/ro.derbederos/untwist.svg?color=red
[javadoc-link]: http://javadoc.io/doc/ro.derbederos/untwist
[license-svg]: https://img.shields.io/badge/license-Apache2-blue.svg
[license-link]: https://raw.githubusercontent.com/csoroiu/untwist/master/LICENSE
[maven-tasks-svg]: https://img.shields.io/maven-central/v/ro.derbederos/untwist.svg
[maven-tasks-link]: https://maven-badges.herokuapp.com/maven-central/ro.derbederos/untwist