Run some experiments to determine the distribution of numbers returned by the new pseudorandom method from the

Question:

Run some experiments to determine the distribution of numbers returned by the new pseudorandom method from the previous project. Recall that this method returns a double number in the range [0..1). Divide this range into 10 intervals and call the method one million times, producing a table such as this:

Range .....................Number of Occurrences
[0.0..0.1) ......................................99889
[0.1..0.2) ....................................100309
[0.2..0.3) ....................................100070
[0.3..0.4) ......................................99940
[0.4..0.5) ......................................99584
[0.5..0.6) ....................................100028
[0.6..0.7) ......................................99669
[0.7..0.8) ....................................100100
[0.8..0.9) ....................................100107
[0.9..1.0) ....................................100304

Run your experiment for different values of the multiplier, increment, and modulus. With good choices for the constants, you will end up with about 10% of the numbers in each interval. A pseudorandom number generator with this equal-interval behavior is called uniformly distributed.


Data from Previous Project

Add a new method to the random number class of the previous project. The new method generates the next pseudorandom number but does not return the number directly. Instead, the method returns this number divided by the modulus. (You will have to cast the modulus to a double number before carrying out the division; otherwise, the division will be an integer division, throwing away the remainder.)

The return value from this new member function is a pseudorandom double number in the range [0..1). (The square bracket, “[”, indicates that the range does include 0, but the rounded parenthesis, “)”, indicates that the range goes up to 1, without actually including 1.)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: