Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
public static double stdev(int a[]){
double mean = 0;
int sum = 0;
//1. Work out the Mean (the simple average of the numbers)
for (int i = 0; i < a.length; i++) {
sum += a[i];
if(i == a.length -1){
mean = sum/a.length;
}
}
//2. Then for each number: subtract the Mean and square the result
//GET DIFFERENCE
double variance = 0;
double [] b = new double [a.length];
for (int i = 0; i < a.length; i++) {
//b[i] = Math.sqrt(Math.abs(a[i] - mean));
double diff = Math.abs(a[i] - mean);
b[i] = diff * diff;
}
//3. Then work out the mean of those squared differences.
for (int i = 0; i < b.length; i++) {
variance += b[i]/b.length;
}
//4. Take the square root of that and you are done!
double standardDeviation = Math.sqrt(Math.ceil(variance));
return standardDeviation;
}
double diff = a[i] - mean;
variance += b[i]/(b.length-1);
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.