Write a program that computes the central tendencies mean av

Write a program that computes the central tendencies mean (average), mode, median and the variation: variance, standard deviation and range for a set of numbers given in the data file ArsenicGroundWaterFile.txt.

The following data represent (naturally occurring) concentration of arsenic in ground water for a random sample of 102 Northwest Texas wells. Units are parts per billion.
Reference: Nichols, C.E. and Kane, V.E., Union Carbide Technical Report K/UR-1

The output should be as follows to two decimal places:

Central Tendency Variation   

Mean xxx.xx Variance xxx.xx

Median xxx.xx Std. Dev xxx.xx

Mode xxx.xx Range xxx.xx

17.6
10.4
13.5
4
19.9
16
12
12.2
11.4
12.7
3
10.3
21.4
19.4
9
6.5
10.1
8.7
9.7
6.4
9.7
63
15.5
10.7
18.2
7.5
6.1
6.7
6.9
0.8
73.5
12
28
12.6
9.4
6.2
15.3
7.3
10.7
15.9
5.8
1
8.6
1.3
13.7
2.8
2.4
1.4
2.9
13.1
15.3
9.2
11.7
4.5
1
1.2
0.8
1
2.4
4.4
2.2
2.9
3.6
2.5
1.8
5.9
2.8
1.7
4.6
5.4
3
3.1
1.3
2.6
1.4
2.3
1
5.4
1.8
2.6
3.4
1.4
10.7
18.2
7.7
6.5
12.2
10.1
6.4
10.7
6.1
0.8
12
28.1
9.4
6.2
7.3
9.7
62.1
15.5
6.4
9.5

Solution

#include numbers; int number; float average, variance, std_deviation, sum = 0, sum1 = 0; fpone.open(\"ArsenicGroundWaterFile.txt\", ios::in | ios::binary); if(fpone.is_open()){ while(fpone >> number){ numbers.push_back(number); fpone.get(); } } fpone.close(); cout << \"Numbers:\ \"; for (int i=0; i < numbers.size(); i++) { cout << numbers[i] << \'\ \'; } /* now we will compute the sum of all elements */ for (i = 0; i < n; i++) { sum = sum + numbers[i]; } average = sum / (float)n; /* now we will Compute variance and standard deviation */ for (i = 0; i < n; i++) { sum1 = sum1 + pow((numbers[i] - average), 2); } variance = sum1 / (float)n; std_deviation = sqrt(variance); printf(\"Average of all elements = %.2f\ \", average); printf(\"variance of all elements = %.2f\ \", variance); printf(\"Standard deviation = %.2f\ \", std_deviation); }
Write a program that computes the central tendencies mean (average), mode, median and the variation: variance, standard deviation and range for a set of numbers
Write a program that computes the central tendencies mean (average), mode, median and the variation: variance, standard deviation and range for a set of numbers
Write a program that computes the central tendencies mean (average), mode, median and the variation: variance, standard deviation and range for a set of numbers

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site