The Random class is a generator of pseudo random numbers. These are called pseudo random,numbers because they are simply uniformly distributed sequences. Random defines the following constructors:
Random Long seed)
The first version creates a number generator that uses the current time as the starting, or seed, value. The second form allows you to specify a seed value manually. ‘ ” If you initialize a Random object with a seed, you define the starting point for the random sequence. If you use the Same seed to initialize another Random object, you will extract the same random sequence. If you want to generate different sequences, specify differentiated values. The easiest way to do this is to use the current time to seed a Random ~abject. This approach reduces the possibility of getting repeated sequences.
As you can see, there are six types of random numbers that you can extract from’ a ‘ Random’ object. Random Boolean values are available from next Boolean( ). Random , bytes can be obtained by calling next Bytes( ). Integers can be extracted via the . next Int( ) method. . integers, uniformly distributed over their range, can be obtained with exponent( ). The next Float( ) and next Double( ) methods return a ” uniformly distributed flOat and double, respectively, between 0.0 and 1.0. Finally, nextGaussian( ) returns a double value centered at 0.0 with a standard deviation of 1.0. ‘This is what is known as a bell curve. ‘ .’ Here is an example that demonstrates the sequence produced by next Gaussian( ). It , obtains 100 random Gaussian values and averages these values. The program also ‘ counts the number of values that fall within two standard deviations, plus or minus, using increments of 0.5 for each category. The result is graphically displayed sideways
on the screen.