https://github.com/gagniuc/linear-congruential-generator
Linear congruential generator (LCG) is an application that demonstrates the generation of pseudo-random numbers. The LCG is a specialized mathematical function (deterministic algorithm) for simulation of “random” numbers. The numbers generated by LCG are called pseudo-random numbers.
https://github.com/gagniuc/linear-congruential-generator
equation generator javascript js linear-congruential-generator pseudorandom random
Last synced: 8 months ago
JSON representation
Linear congruential generator (LCG) is an application that demonstrates the generation of pseudo-random numbers. The LCG is a specialized mathematical function (deterministic algorithm) for simulation of “random” numbers. The numbers generated by LCG are called pseudo-random numbers.
- Host: GitHub
- URL: https://github.com/gagniuc/linear-congruential-generator
- Owner: Gagniuc
- License: mit
- Created: 2021-10-28T21:16:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T11:05:30.000Z (over 3 years ago)
- Last Synced: 2025-01-15T07:31:58.404Z (9 months ago)
- Topics: equation, generator, javascript, js, linear-congruential-generator, pseudorandom, random
- Language: HTML
- Homepage:
- Size: 152 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Linear congruential generator
Linear congruential generator (LCG) is an application that demonstrates the generation of pseudo-random numbers. The LCG is a specialized mathematical function (deterministic algorithm) for simulation of “random” numbers. The numbers generated by LCG are called pseudo-random numbers. This name comes from the fact that the random numbers are generated based on mathematical formulas, which explode an initial “seed” (usually, a number extracted from the computer clock) into a sequence of numbers that follow a pattern. Thus, each new number in the sequence will be dependent on the previous number provided by the same formula. The classical example of a pseudo-random generator is the linear congruential generator (Xn+1 = (a × Xn + c) mod m):
```
X[n+1] = (a × X[n] + c) mod m
```Where X1 is an integer seed, n indicates the total number of terms in the sequence, m is the modulus, a is the multiplier, and c is the increment. The pattern of such a function shows a characteristic distribution for long numerical sequences that exceed the period (the cycle of repetition). The range of numbers of the above function is between 0 and m−1, with a uniform distribution of integers. The length of a period can be controlled by setting the value of m. However, a narrow portion over this sequence shows a small piece of the wider pattern, thus simulating randomness without showing the real distribution derived from the initial seed (X1). This subject of pseudo-random numbers is related to a philosophical discussion from the book entitled Algorithms in Bioinformatics: Theory and Implementation. Note that the construction and theory behind the chart of this application can be found [here](https://github.com/Gagniuc/World-smallest-js-chart-v1.0).
**Live demo**: https://gagniuc.github.io/Linear-congruential-generator/
# References
- Paul A. Gagniuc. Algorithms in Bioinformatics: Theory and Implementation. John Wiley & Sons, Hoboken, NJ, USA, 2021, ISBN: 9781119697961.