subject

The provided code reads in data from a file and stores it in a vector named signal. Three functions prototypes are declared at the top named mean, stdev, and median.
Define these functions to calculate the mean, standard deviation, and median of the values in the signal vector.

#include
using namespace std;
// Function prototypes. You must define these functions after main().
double mean( vector &sig );
double stdev( vector &sig );
double median( vector &sig );

int main(){
// create object to read in data
ifstream inFile;
double mean( vector &sig ){
// Fill in function definition
// The vector sig is in scope here, so you can use it
// Return the mean value
}

double stdev( vector &sig ){
// Fill in function definition
// The vector sig is in scope here, so you can use it
// Return the stdev
}

double median( vector &sig ){
// Fill in function definition
// The vector sig is in scope here, so you can use it
// Return the median value
}
// read in filename
string fname;
cout << "Provide an input file name: " << endl;
cin >> fname;

// open file and confirm that it is open
inFile. open(fname);
if (!inFile. is_open()){
cout << "Could not open file " << fname << "." << endl;
return -1;
}

// read in numbers from file and store in a vector
vector signal(0);
while( !inFile. eof() ){
double tmp;
inFile >> tmp;
signal. push_back( tmp );
}
signal. pop_back();

printf(" Average: %lf\n", mean( signal ));
printf("Standard deviation: %lf\n", stdev( signal ));
printf(" Median: %lf\n", median( signal ));

// close file
inFile. close();

return 0;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 08:30
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
question
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have used—for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
question
Computers and Technology, 24.06.2019 12:30
Do you think media is stereotype ? and why?
Answers: 1
question
Computers and Technology, 25.06.2019 01:00
Why is outfitting a workplace with video games in a technology development company consiered a strategic use of money
Answers: 1
You know the right answer?
The provided code reads in data from a file and stores it in a vector named signal. Three functions...
Questions
question
Social Studies, 10.07.2019 12:50
Questions on the website: 13722359