Introduction
• Random NumberGenerators (RNGs) produce
sequences that appear random.
• Two types: True RNGs (TRNGs) and Pseudo
RNGs (PRNGs).
• Used in cryptography, simulations, games,
statistical sampling, etc.
3.
Classifications of RNGAlgorithms
• True RNGs (TRNG): Use physical processes
(e.g., thermal noise).
• Pseudo RNGs (PRNG): Use deterministic
algorithms.
• PRNGs are faster and easier to implement.
4.
Linear Congruential Generator
(LCG)
•Formula: X_{n+1} = (aX_n + c) mod m
• Deterministic and easy to implement.
• Example: a=1664525, c=1013904223, m=2^32
• With seed=1234: sequence =
[0.7143076679203659]
XORShift Algorithm
• Simpleand fast bitwise operation based
generator.
• x ^= x << 13; x ^= x >> 17; x ^= x << 5
• Works well for embedded systems.
• Less randomness compared to Mersenne
Twister.
9.
Middle Square Method
•Square the number and take middle digits as
next number.
• Simple, but has short cycle and can lead to
zero quickly.
• Used in early computer simulations.
10.
Advantages & Disadvantages
•LCG: Fast but poor randomness.
• Mersenne Twister: Great for simulation, not
for crypto.
• TRNG: Truly random but hardware dependent.
• XORShift: Lightweight but limited randomness
quality.
11.
Applications of RNGs
•Cryptography: Secure key generation.
• Simulations: Monte Carlo methods.
• Games: Random events and outcomes.
• Statistical Sampling: Unbiased sample
selection.
• Machine Learning: Weight initialization, data
shuffling.
12.
Conclusion
• RNGs areessential in computing and
modeling.
• PRNGs dominate due to ease of use and
speed.
• Algorithm choice depends on the application.
• Understanding helps in choosing the right one.