Question: C++ program: In engineering simulations, we often want to generate a floating-point sequence of values with a specified mean and variance. The randFloat function below
C++ program:
In engineering simulations, we often want to generate a floating-point sequence of values
with a specified mean and variance. The randFloat function below allows us to generate a
random sequence between limits a and b, but it does not allow us to specify the mean and
variance. By using results from probability, the following relationships can be derived
between the limits of a uniform random sequence and its theoretical mean ? and variance ?2:
/*This function generates a random double value between a and b*/
double randFloat (double a, double b)
{
return a + (static_cast(rand()) / RAND_MAX) * (b - a);
}
Part 1:
Write a program that uses the randFloat function given above to generate
sequences of random floating-point values between 4 and 10. You should now use two
specific sized sequences; sequences of 100 and 10,000. Then compare the computed
mean and variance to the theoretical values computed (using formulas above).
There should be no user input for this section.
The expected output should be seen for both sequences: theoretical mean, practical mean,
theoretical variance, practical variance. The values should be separated by spaces.
Example:
Given: theoretical mean = 2.0, practical mean = 2.1, theoretical variance = .75, and
practical variance = .76
The output would be: 2.0 2.1 0.75 0.76
Output should be seen with this output style for both sequences, each started on a
newline.
Use srand(500);
Required output:

7 7.04755 3 3.01372 3 7 7.00747 3 3.00782
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
