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, 21.06.2019 18:30
Which number on the image above correctly indicates the name of a folder in this url? a.1b.2c.3d.4
Answers: 2
question
Computers and Technology, 21.06.2019 22:00
Some of your friends have gotten into the burgeoning field of time-series data mining, in which one looks for patterns in sequences of events that occur over time. purchases at stock exchanges"what's being bought" are one source of data with a natural ordering in time. given a long sequence s of such events, your friends want an efficient way to detect certain "patterns" in them"for example, they may want to know if the four events buy yahoo, buy ebay, buy yahoo, buy oracle occur in this sequence s, in order but not necessarily consecutively. they begin with a collection of possible events (e.g., the possible transactions) and a sequence s of n of these events. a given event may occur multiple times in s (e.g., yahoo stock may be bought many times in a single sequence s). we will say that a sequence s is a subsequence of s if there is a way to delete certain of the events from s so that the remaining events, in order, are equal to the sequence s . so, for example, the sequence of four events above is a subsequence of the sequence buy amazon, buy yahoo, buy ebay, buy yahoo, buy yahoo, buy oracle their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of s. so this is the problem they pose to you: give an algorithm that takes two sequences of events"s of length m and s of length n, each possibly containing an event more than once"and decides in time o(m + n) whether s is a subsequence of s.
Answers: 3
question
Computers and Technology, 22.06.2019 00:10
How does access indicates that a filter has been applied to a specific column
Answers: 1
question
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
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
Computers and Technology, 15.11.2019 02:31
question
Mathematics, 15.11.2019 02:31
question
Mathematics, 15.11.2019 02:31
question
Mathematics, 15.11.2019 02:31