I need to create an arrangement with the following numbers and calculate:
By line: The average and the standard deviation
The average and standard deviation of the entire arrangement
{3,8,7,6} {7,5,7,4} {3,2,1,0} {9,6,4,8}
This is what I'm carrying but it does not work on the deviation part and apparently it just copes with the whole arrangement
public class arreglo4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int data[][] = { { 3, 8, 7, 6 }, { 7, 5, 7, 4 }, { 3, 2, 1, 0 }, { 9, 6, 4, 8 } };
// acumulador
double sum = 0;
for (int i = 0; i < data.length; i++) {
sum = sum + data.length;
}
// desplegar
for (int ren = 0; ren < data.length; ren++) {
for (int col = 0; col < data[ren].length; col++) {
System.out.println(data[col][ren] + "\t");
}
System.out.println();
}
// promedio
double mean = sum / data.length;
System.out.println("promedio " + mean);
// Desviacion
double sum1 = 0;
for (int i = 0; i < data.length; i++) {
sum1 = sum1 + ((data[i]-mean) * (data[i]-mean));
}
double s=Math.sqrt(sum1/(data.length-1));
System.out.println("La desviacion es " +s);
}
}