我想问下平均差值怎么算??
我是问的平均差值不是平均值。。
avg(平均値)=sum(总和) / num(个数)
public static void main(String[] args) {
double a = 4; double b = 6; double c = 9;
double avg = (a+b+c)/3.0;
double meanDifference;
meanDifference = (Math.abs(a - avg) + Math.abs(b - avg)+Math.abs(c - avg))/3.0;
System.out.println(avg);
System.out.println(meanDifference);
}
sum是相加之后的和,除以数的个数就是平均数了。