This is a C++ project for generating random numbers using different methods:
- ICG (Inversive Congruential Generator)
- MSM (Middle Square Method)
- LFG (Lagged Fibonacci Generator)
- MRG (Multiple Recursive Generators)
- KS Test (Kolmogorov-Smirnov Test)
This project implements various algorithms for generating random numbers and includes a method for testing the generated sequence with the KS (Kolmogorov-Smirnov) test. The methods implemented are as follows:
- ICG (Inversive Congruential Generator): Generates random numbers using the ICG rule: X(i+1) = (a / Xi) % m.
- MSM (Middle Square Method): Generates random numbers using the MSM rule: X(i) = (Xi)^2 -> mid % m.
- LFG (Lagged Fibonacci Generator): Generates random numbers using the LFG rule: X(i) = (Xi - j operator Xi - k) % m.
- MRG (Multiple Recursive Generators): Generates random numbers using the MRG rule: X(i+1) = sum(an * Xi - q) % m.
- KS Test (Kolmogorov-Smirnov Test): Performs the Kolmogorov-Smirnov test to evaluate the uniformity of the generated sequence.
-
Clone this repository: git clone https://github.com/NermeenKamal/random-number-generator.git
-
Navigate to the project directory: cd random-number-generator
-
Compile the code: g++ -o random_number_generator random_number_generator.cpp
-
Run the program: ./random_number_generator
-
Follow the on-screen instructions to generate random numbers and perform the KS Test.
-
ICG:
- Enter method number
1
. - Provide the required inputs.
- Generated random numbers will be displayed.
- Enter method number
-
MSM:
- Enter method number
2
. - Provide the required inputs.
- Generated random numbers will be displayed.
- Enter method number
-
LFG:
- Enter method number
3
. - Provide the required inputs.
- Generated random numbers will be displayed.
- Enter method number
-
MRG:
- Enter method number
4
. - Provide the required inputs.
- Generated random numbers will be displayed.
- Enter method number
-
KS Test:
- Enter method number
5
. - Choose whether you want to provide your own random numbers or not.
- Perform the test.
- Enter method number