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, 22.06.2019 22:00
What is a distinguishing feature of today’s graphic application software?) graphic applications are used today on a variety of devices, including touch-screen kiosks and mobile phones.
Answers: 3
question
Computers and Technology, 23.06.2019 02:00
Arecipients list has been loaded into a document. which commands should be clicked in order to filter the list so that letters will not be printed for recipients who live in a certain state? mailings tab, start mail merge, select recipients, type new list, then insert only contacts from the desired states mailings tab, rules, select recipients, use existing list, then choose a recipients list that includes only contacts in certain states mailings tab, select recipients, use existing list, rules, fill in, then type in certain states mailings tab, rules, skip record select “state” under field name, then type in the state name under “equal to”
Answers: 2
question
Computers and Technology, 23.06.2019 23:00
Computer programming is one type of what career
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
In three to five sentences, describe how you can organize written information logically and sequentially
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
Mathematics, 17.01.2021 02:30
question
Arts, 17.01.2021 02:30
question
English, 17.01.2021 02:30
question
Mathematics, 17.01.2021 02:30
question
Mathematics, 17.01.2021 02:30
question
Social Studies, 17.01.2021 02:40
Questions on the website: 13722361