https://github.com/iprit/lehmer-generator
Lehmer Pseudorandom Number Generator
https://github.com/iprit/lehmer-generator
Last synced: 10 months ago
JSON representation
Lehmer Pseudorandom Number Generator
- Host: GitHub
- URL: https://github.com/iprit/lehmer-generator
- Owner: IPRIT
- Created: 2015-10-04T02:46:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-04T18:27:19.000Z (over 10 years ago)
- Last Synced: 2025-03-05T23:44:14.524Z (over 1 year ago)
- Language: C#
- Size: 148 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lehmer Linear Congruent Pseudorandom Number Generator CRAY
The current generator named as *CRAY* allows to generate numbers included in the interval from 0 to 1 with period 2^46 and binary modulo exponentiation and multiplication.
The selected values for the Lehmer generator:
```a = 44 485 709 909 377, c = 0, m = 2^48, X0 = 1.```
#### You can create random variables with a single basic interval.
```c#
CBasicRandomValue basicGenerator = new CBasicRandomValue();
for (int i = 0; i < 100000; ++i)
basicGenerator.next();
```
#### You can also create random variables using a factory, which divides produced sequence of numbers into several parts and gives a better result.
```c#
int seed = 1234;
CLinearCongruentGenerator linearGenerator = new CLinearCongruentGenerator(seed);
CBasicRandomValue basicGeneratorFirst = new CBasicRandomValue(linearGenerator);
for (int i = 0; i < 1 << 20; ++i)
basicGeneratorFirst.next();
CBasicRandomValue basicGeneratorSecond = new CBasicRandomValue(linearGenerator);
for (int i = 0; i < 1 << 20; ++i)
basicGeneratorSecond.next();
```