Question
Objectives: 1. Practice using one dimensional arrays and functions (with parameters) to implement algorithms to solve a problem. 2. Practice file input. 3. Understand the
Objectives:
1. Practice using one dimensional arrays and functions (with parameters) to implement algorithms to solve a problem.
2. Practice file input.
3. Understand the mathematics of basics statistics: min, max, mean, standard deviation, linear regression and correlation.
4. Be able to write a C++ program to compute basic statistics.
Instructions:
1. Read the data file which contains two fields, the x and y coordinates. Do NOT ask the user to enter the filename. The first line contains the number of coordinates in the file.
2. As you read the file, load the x coordinates into one array and the y coordinates into another array.
3. Print out all values. All couts must be in the main part of the program. Format is up to you. Be sure you are descriptive.
4. No global variables.
5. Make sure you add a system(pause) before the return and before any exits.
6. Add comments and white space as needed.
7. Use the formulas as shown below.
Formulas:
Given data sets: X = {x0, x1, ..., xn-1}, Y = {y0, y1, ..., yn-1}
Functions
Below are the function prototypes of the functions you must create. You are free to use your own variable names. You may create other functions if needed.
Note: n is the number of entries in the array, z[ ] is an array which is either x[ ] or y[ ] depending on which is sent to the function. You are to compute the range, mean, and std deviation for both x and y.
void calcRange (double z[ ], int n, double& min, double& max); //Return min & max
double calcMean (double z[ ], int n); // Return the mean of the array
double calcStdDev (double z[ ], int n, double mean); // Return the std deviation of the array
void calcRegression (double x[ ], double y[ ], int n, double& a, double& b); //Returns a and b
double calcCorrelation(double stdDevx, double stdDevy, double a); // Compute correlation coefficient
Input/Output to the Console
Output is up to you. Be sure to print out all fields and make sure they are labeled correctly. Remember all cout must come from the main part of the program. I want to make sure you are passing your values correctly. Sample output:
Formula Nanne The Mean (average) ? n-1 Standard Deviation ? n-1 Correlation Equation: y = ax + b Slope a Intercept bStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started