In the past few weeks, we have learned some of the details about Monte Carlo simulation.† Letís see if we can write a program to implement it.† Here is what you need to do:
Individual Part (one function per group member):
Write four functions, one for each of the following tasks, test the function on your own then meet with your group.† If you need data points, create some fake values.† Meet as a group to make sure each function meets the standards defined below.† You do not have to put together these functions.† Each function should work individually and be tested individually.† You will submit a copy of your function and the test result for next week.
void create_test_samples(double x[ ], int size, double low, double high);
// This function creates size number of random values between low and high.†
// It will store those values in array x. It will test the values to make sure they have a
// uniform distribution.† For now you can divide the interval in equally spaced intervals // (you decide how many) and count the number of random values that appears in each
// interval.† In theory, if you have a perfect distribution you should have
// the same number in each interval.† There are several pre-defined random generators
// in C++.† You decide which to use or write your own random generator function.
double compute_error(double x, double y, int size);
// This function computes the error associated with your calculations.
// That is basically the standard deviation.† In this function x is the
// array of random points, y is the array of computed values for each
// value of x.† So they are in the same size.† For testing you can generate
// an array of x and y values. Example: y = 2x.
void documentation(int& low, int& high)
// Explain what the complete program will do and how one can run it
// Must include description of input/output values. It also asks for the
// upper and lower limit of integral and stores them in low and high
void compute_function(double y,double x[ ], int size);
// This will compute the value of yi = f(xi).† Thus, it computes the value of y at each
// x and stores the result in y.† For example if f(x) = 2x, and the low number was
// 0, then f(0) = 2*0 = 0. This value gets stored in y.††††
Submit a group report for the discussions you had regarding the functions.† Please try to stay with these functions as much as you can. Assume I am the mean old boss that I canít think any other way and I want the functions to be that way.† Of course, I hope I am correct.