This project is a continuation of the previous project. Many applications require pseudorandom number sequences that are

Question:

This project is a continuation of the previous project. Many applications require pseudorandom number sequences that are not uniformly distributed. For example, a program that simulates the birth of babies can use random numbers for the birth weights of the newborns. But these birth weights should have a Gaussian distribution. In a Gaussian distribution, numbers form a bellshaped curve in which values are more likely to fall in intervals near the center of the overall distribution. The exact probabilities of falling in a particular interval can be computed by knowing two numbers: 

(1). A number called the variance, which indicates how widely spread the distribution appears,

(2). The center of the overall distribution, called the median. For this kind of distribution, the median is equal to the arithmetic average (the mean) and equal to the most frequent value (the mode).

Generating a pseudorandom number sequence with an exact Gaussian distribution can be difficult, but there is a good way to approximate a Gaussian distribution using uniformly distributed random numbers in the range [0..1). The approach is to
generate three pseudorandom numbers r1, r2,and r3, each of which is in the range [0..1). These numbers are then combined to produce the next number in the Gaussian sequence. The formula to combine the numbers is:

Next number in the Gaussian sequence

= median + (2 × (r1 + r2 + r3) - 3 ) × variance

Add a new method to the random number class, which can be used to produce a sequence of pseudorandom numbers with a Gaussian distribution.


Data from Previous Project

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.

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

Step by Step Answer:

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