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 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 3
question
Computers and Technology, 23.06.2019 06:40
What are the three uses of a screw?
Answers: 2
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 24.06.2019 02:00
Read the following scenario, and then answer the question below. you want to send an e-mail to your boss requesting a meeting to discuss a raise. what is the best example of an e-mail to an employer about this meeting? “hey jason. can we chat about getting me more money soon? let me know. peace, meg.” “hello jason. pardon me for sending yet another e-mail today about my need to talk to you about my position and a possible pay increase. i am dying to know when you can talk. sincerely, meg.” “hello jason. i have been with the company for one year and have taken on more responsibilities than outlined in my job description. i would appreciate an opportunity to speak with you about my position. let me know when we can schedule a meeting. you, meg.” “greetings jason! i hope this e-mail finds you well and happy today. i really, really want to talk to you about something important. i am not sure if you have time. i hope you do. get back in touch with me and let me know when we might talk. ever so much for taking the time to read this. sincerely, meg.”
Answers: 3
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
English, 25.03.2020 06:38
Questions on the website: 13722361