I am to find the standard deviation. When calculating the standard deviation, my outputs are way higher than the given sample. How do I go calculating the standard deviation of each column?
Here is my code as reference:
double[] average = new double[arrScores.length];
for (int i = 0; i < arrScores[i].length; i++) {
double sum = 0;
for (int j = 0; j < arrScores.length; j++) {
sum = sum + arrScores[j][i];
}
average[i] = sum / arrScores.length;
System.out.printf("Test#%d: %.2f with Std Deviation: \n", i, average[i]);
average[i]=0;
The array given is as follows:
100.00 90.00 100.00 80.00 70.00
50.00 60.00 70.00 80.00 100.00
60.00 70.00 100.00 80.00 90.00
69.50 70.50 80.50 30.50 0.00
78.30 69.50 48.00 90.00 100.00
88.50 95.00 100.00 99.00 0.00
Output to be made is:
Test#0 Average: 74.38 with Std Deviation: 16.81
Test#1 Average: 75.83 with Std Deviation: 12.39
Test#2 Average: 83.08 with Std Deviation: 19.44
Test#3 Average: 76.58 with Std Deviation: 21.76
Test#4 Average: 60.00 with Std Deviation: 43.59
EDIT:
double Stats = 0;
double Class = 0;
double average = 0;
double[] arr=new double[arrScores.length];
for(int i = 0; i < arrScores[i].length; i++){
for(int j = 0; j < 6; j++){
average = average +array[j][i];
arr[j]=array[j][i];
}
average =average / arrScores[i].length;
for(double num; num < arrScores.length; num++){
Stats = Stats+ Math.pow(num-average,2);
}
Class=Math.sqrt(Stats / arrScores[i].length);
This is what I had before changing to to what I had above.