Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C-programing-Create functions to calculate the following statistical measures to give the user information about each data set: -mean (the average) - median (the middle value)

C-programing-Create functions to calculate the following statistical measures to give the user information about each data set:

-mean (the average)

- median (the middle value)

- variance (the average of the square of difference between value and the mean)

- standard deviation (the square root of variance) ? average power (the average of the squared value)

- average amplitude (the average absolute value) ? zero crossings (the number of times consecutive values cross the x-axis)

Write the results to a file in append mode AND display results on screen.

Example of a function to calculate average power of an array: double ave_power(double x[], int n)

{ // Declare and initialize objects. double sum(0); // Determine average power for (int k=0; k<=n-1; ++k)

{ sum += x[k]*x[k];

} // Return average power return sum/n; }

In this function, x is the parameter for the data array, and n is the parameter for size of the array. You may not need n, depending on how you detect the end of the data file. Save the output file. Your archived tar file must include the input and output text files as well as your source code and compiled program.

More information: mean (the average) The sum of all data values divided by the number of data mean(x[i]) = ? ???? ?? median (the middle value) Sort the data from smallest to largest, then return the middle value x[n/2] The median function should call a sort function to put the data in order before it returns the middle value. variance (the average of the squared difference between value and mean) variance(x[i]) = ?(????????) 2 ?? standard deviation (the square root of variance) The standard deviation function should call the variance function then return the square root of variance. The square root function is sqrt(), and it takes a double argument and returns a double. Make sure to include the preprocessor statement to call the math library: #include average power (the average of the squared value) average_power(x[i]) = ?(???? 2) ?? average amplitude (the average absolute value) average_amplitude(x[i]) = ?|???? | ?? The absolute value function for double data type is fabs(). Be sure to call the math library. zero crossings (the number of times consecutive values cross the x-axis)

Create your algorithm for counting the zero axis crossings. One approach is to count every time when two consecutive values have opposite sign. (How will you handle zero values when counting zero crossings?)

The attached file contain approximately 1000 data points per file.

These are the data(its too long so i put the first few numbers for each one of them

TwoA.dat

-1.1230469e-02 -9.7656250e-03 -9.2773438e-03 -8.3007812e-03 -7.3242188e-03 -5.8593750e-03 -4.8828125e-03 -4.8828125e-03 -4.3945312e-03 -3.4179688e-03 -2.9296875e-03 -1.4648438e-03 -4.8828125e-04 4.8828125e-04 9.7656250e-04 0.0000000e+00 1.9531250e-03 4.3945312e-03 6.3476562e-03 7.3242188e-03 7.3242188e-03 8.7890625e-03 1.0742188e-02 1.1230469e-02 1.1718750e-02 9.7656250e-03 -6.8359375e-03 -9.1796875e-02 -3.5156250e-02 3.9550781e-02 -2.0019531e-02 3.3203125e-02 -4.8828125e-04

TwoB.dat

-1.8066406e-02 -1.3183594e-02 -9.7656250e-03 -2.4414062e-03 2.4414062e-03 6.8359375e-03 1.3183594e-02 1.6113281e-02 2.0507812e-02 2.3437500e-02 2.2460938e-02 1.7578125e-02 1.7578125e-02 6.3476562e-03 0.0000000e+00 -1.0742188e-02 -2.0019531e-02 -3.0761719e-02 -3.5156250e-02 -4.3945312e-02 -4.7363281e-02 -4.8828125e-02 -4.9316406e-02 -4.5410156e-02 -3.9062500e-02 -3.4667969e-02 -2.5878906e-02 -1.4648438e-02 -5.3710938e-03 1.0742188e-02 2.9296875e-02 4.9316406e-02 7.8613281e-02 1.1035156e-01 1.3183594e-01 1.5234375e-01 1.6455078e-01 1.5771484e-01 1.4843750e-01 1.1718750e-01 7.7636719e-02 3.5156250e-02

TwoC.dat

 1.2695312e-02 2.5390625e-02 -3.4179688e-03 5.2734375e-02 3.1738281e-02 5.9082031e-02 5.5664062e-02 4.1992188e-02 3.0273438e-02 -8.3007812e-03 -4.8339844e-02 -5.6152344e-02 -4.4921875e-02 -8.3007812e-03 0.0000000e+00 1.7578125e-02 2.9296875e-02 4.5410156e-02 3.6621094e-02 2.3437500e-02 -1.5625000e-02 1.9531250e-03 -2.4414062e-03 4.8828125e-03 -1.8554688e-02 -3.9062500e-03 -9.2773438e-03 2.4902344e-02 9.7656250e-03 2.3437500e-02 1.9531250e-03 6.8359375e-03 -2.3437500e-02 -6.8359375e-03 -8.7890625e-03 -1.5136719e-02 -1.6601562e-02 -2.7343750e-02 -1.8066406e-02 -1.5136719e-02 -7.8125000e-03 -2.6367188e-02 -3.9062500e-03 -3.2714844e-02 0.0000000e+00 -1.2695312e-02 0.0000000e+00 -1.9531250e-02 -1.5136719e-02 -3.1738281e-02 -1.7578125e-02 -4.5898438e-02 -4.8339844e-02 -7.0312500e-02 -8.8378906e-02 -1.1035156e-01 -1.0009766e-01 -1.1523438e-01 -1.1914062e-01 -1.1767578e-01 -1.1816406e-01 -1.1865234e-01 -8.8378906e-02 -7.8125000e-02 -3.9550781e-02 -1.1230469e-02 2.0507812e-02 3.6132812e-02 8.5449219e-02 8.9355469e-02 1.4062500e-01 1.4111328e-01 1.5869141e-01 1.5820312e-01 1.5966797e-01 1.5771484e-01 1.4599609e-01 1.5332031e-01 1.0009766e-01 1.2158203e-01 5.6152344e-02 6.5917969e-02 9.2773438e-03 0.0000000e+00 -5.6640625e-02 -6.1035156e-02 -1.1181641e-01 -1.1474609e-01 -1.3867188e-01 -1.3427734e-01 -1.4453125e-01 -1.2500000e-01 -1.2353516e-01 -9.8632812e-02 -5.3222656e-02 -4.4433594e-02 8.3007812e-03 1.6113281e-02 5.7617188e-02 6.9335938e-02 1.1669922e-01 1.1914062e-01 1.3330078e-01 1.2304688e-01 1.1279297e-01 9.4726562e-02 7.4218750e-02 5.1269531e-02 3.2714844e-02 1.1718750e-02 6.8359375e-03 1.9531250e-02 1.3183594e-02 4.2480469e-02 4.1015625e-02 4.0527344e-02 4.4921875e-02 4.1503906e-02 3.2714844e-02 3.5156250e-02 2.2460938e-02 1.4648438e-02 4.3945312e-03 -4.8828125e-03 -2.0019531e-02 -4.0039062e-02 -5.3710938e-02 -6.7871094e-02 -8.9355469e-02 -9.3261719e-02 -9.2773438e-02 -1.2109375e-01 -1.0839844e-01 -1.1572266e-01 -1.2695312e-01 -1.0253906e-01 -8.4960938e-02 -7.2265625e-02 -3.0273438e-02 -3.9062500e-03 2.0507812e-02 5.0781250e-02 8.4472656e-02 8.1054688e-02 1.0107422e-01 9.8632812e-02 9.5214844e-02 7.9101562e-02 7.5683594e-02 3.0273438e-02 5.0781250e-02 3.0761719e-02 4.4433594e-02 4.6386719e-02 5.6152344e-02 4.3945312e-02 4.8339844e-02 5.3222656e-02 3.0273438e-02 6.1035156e-02 3.0761719e-02 3.4667969e-02 2.5390625e-02 7.3242188e-03

Zero.dat

1.7578125e-02 1.9531250e-02 2.0507812e-02 2.1484375e-02 2.3925781e-02 2.5390625e-02 2.6855469e-02 2.8320312e-02 2.9296875e-02 2.8808594e-02 2.7832031e-02 2.6855469e-02 2.7343750e-02 2.6367188e-02 2.4414062e-02 1.8554688e-02 1.5625000e-02 1.5625000e-02 1.2207031e-02 8.3007812e-03 4.8828125e-03 1.4648438e-03 0.0000000e+00 -2.9296875e-03 -5.3710938e-03 -6.8359375e-03 -8.3007812e-03 -9.2773438e-03 -1.1718750e-02 -1.3183594e-02 -1.7578125e-02 -1.9042969e-02 -2.0996094e-02 -2.4414062e-02 -2.4902344e-02 -2.4414062e-02 -2.4414062e-02 -2.4414062e-02 -2.2460938e-02 -2.0507812e-02 -1.6601562e-02 -1.2695312e-02 -9.2773438e-03 -6.3476562e-03 -1.9531250e-03 1.4648438e-03 6.3476562e-03 8.3007812e-03 1.2695312e-02 1.3671875e-02 1.4160156e-02 1.3671875e-02 1.2695312e-02 1.0742188e-02 7.8125000e-03

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

Students also viewed these Databases questions