There are many different ways to generate random numbers on a computer, most random number generators use the linear congruential relationship. This congruential generator produces a sequence of integers between and :
The initial value is the seed, is the constant multiplier, is the increment, and is the modulus. The value value of equals the reminder from the divison of by . The random number between 0 and 1 is then generated using the equation:
We use the class ‘Random’ in .NET Core, which used the system clock as seed:
– Random floating-point number that is greater than or equal to 0.0, and less than 1.0:
static Random randomX = new Random(); decimal rnX = Convert.ToDecimal(randomX.NextDouble());
– Random number number that is greater than or equal to x, and less than y:
static Random randomX = new Random(); decimal rnX = Convert.ToDecimal(randomX.Next(x, y));
The probability factor
Suppose it is required to generate random numbers using a probability component