Hey guys I have a quick question on my hw, I have found everything needed except the "unusual scores". this is the direction given:
Determine which of the grades, if any, are "unusual" in the sense that their corresponding z-score is < -2.0 or > +2.0. A z-score is computed as:
I know what the x bar and the s is, but I am unsure of what the first x is pertaining to. Can anyone give me a few tips?
Thanks
public class hw05 {
public static void main( String [] args ) {
int [] grades = {98, 87, 78, 100, 99, 67, 69, 50,
88, 100, 88, 79, 60, 75, 93, 97,
40, 98, 88, 62, 58, 85, 92, 93,
59, 98, 94, 95, 87, 47, 69, 79,
89, 85, 68, 75};
int i;
System.out.println("Original grades:");
printArray(grades);
System.out.printf("\n\nNumber of grades: %6d", grades.length);
System.out.printf("\nMaximum grade: %9d", maxArray(grades));
System.out.printf("\nMinimum grade: %9d", minArray(grades));
System.out.printf("\nMean: %.1f", mean(grades));
System.out.printf("\nStandard Deviation: %.1f", stdDev(grades));
}
public static void printArray(int [] a) {
for (int i = 0; i < a.length; i++ ) {
System.out.printf("%6d", a[i]);
if ((i + 1) % 5 == 0)
System.out.printf("\n");
}
}
public static int maxArray(int [] a) {
int max = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i++)
if (a[i] > max)
max = a[i];
return max;
}
public static int minArray(int [] a) {
int min = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i++)
if (a[i] < min)
min = a[i];
return min;
}
public static int sumGrades(int [] a) {
int sum = 0;
for (int i = 0; i < a.length; i++)
sum += a[i];
return sum;
}
public static double mean(int [] a) {
return (double)sumGrades(a) / a.length;
}
public static double sumSquares(int [] a) {
double ss = 0.0;
for (int i = 0; i < a.length; i++)
ss += (a[i] - mean(a)) * (a[i] - mean(a));
return ss;
}
public static double stdDev(int [] a) {
return Math.sqrt(sumSquares(a) / (a.length - 1));
}
}