如何使用JAVA来计算标准偏差 [英] How to calculate standard deviation using JAVA
问题描述
我很新来的,
此刻我想计算的Java标准偏差(我GOOGLE了它哈哈)
但我有很多问题,在得到它的工作。
我有一个由用户inputed十个值,然后我需要计算的标准偏差
我的理解到目前为止感谢的人谁也回答
是
我发现阵列的平均
然后完成计算
双倍二级=总[2];
双三=总[3];
双四=总[3];
双五=总[4];
双六=总[6];
七夕=总[7];
双八=总[8];
双九=总[9];
双十=总[10]; 双十一= average_total;
平均=一个+两台+三位四个都+ 5 +六秒以上7 + 8 + 9 +10 + 11;平均=平均/ 11;
// 1 =一个 - 均值;
//System.out.println(\"I真的希望这种打印出的值:+一个);
* /
// 11 = average_total - 均值;
// 11 = Math.pow(average_total,average_total);
// stand_dev =(一个+两台+三位四个都+ 5 +六秒以上7 + 8 + 9 +10 +十一);
// stand_dev = stand_dev - 均值;
// stand_dev =(stand_dev - 平均值)*(stand_dev - 平均值);
// stand_dev =(stand_dev / 11);
// stand_dev =的Math.sqrt(stand_dev);
我已经有存储在10个值的数组我的数据,但我也不太清楚
如何打印出数据的数组,然后做了计算,不必在这里存储输入code
数据的一些别的地方,我操纵
感谢您的时间,很多AP preciated:)
计算平均阵列。 通过循环值 数组值=(索引值 - 平均值)^ 2 计算新阵列的总和。 由数组长度划分总和 平方根它
编辑:
我会告诉你如何通过数组循环,一切都是pretty多少只是一个不同的计算同样的步骤。
//计算平均值。INT总= 0;的for(int i = 0; I< array.length,我++){
总+ =阵列[我] //这是总结的所有值的计算
}双平均=总/ array.length;
EDIT2:
阅读你的code之后,你正在做的不对的地方在于你是不是通过值循环和平均正确减去它。
又名这一部分。
十一= average_total - 均值;结果
11 = Math.pow(average_total,average_total);
块引用>您需要做到这一点。
的for(int i = 0; I< array.length,我++){
数组[我] = Math.pow((数组[我] -mean),2)
}基本上你需要NEWVALUE = OLDVALUE数组中改变每个值 - 平均值(平均)
然后计算总和......然后开方的。
I'm very new here, at the moment I am trying to calculate standard deviation with Java (I have googled it haha) but I am having a lot of issues on getting it working
I have ten values that are inputed by a user which I then have to calculate the standard deviation of my understanding so far thanks to people who have replied is I find the mean of the array then complete the calculations
double two = total[2]; double three = total[3]; double four = total[3]; double five = total[4]; double six = total[6]; double seven = total[7]; double eight = total[8]; double nine = total[9]; double ten = total[10]; double eleven = average_total; mean = one + two + three + four + five + six + seven + eight + nine + ten + eleven; mean = mean/11; //one = one - mean; //System.out.println("I really hope this prints out a value:" +one); */ //eleven = average_total - mean; //eleven = Math.pow(average_total,average_total); //stand_dev = (one + two + three + four + five + six + seven + eight + nine + ten + eleven); //stand_dev = stand_dev - mean; // stand_dev = (stand_dev - mean) * (stand_dev - mean); // stand_dev = (stand_dev/11); // stand_dev = Math.sqrt(stand_dev);
I already have my data that is stored in an array of 10 values but I am not too sure how to print the data out of the array then do the calculations with out having to store the enter code here data some where else that I have manipulated
Thank you for your time, much appreciated :)
解决方案calculate mean of array. loop through values array value = (indexed value - mean)^2 calculate sum of the new array. divide the sum by the array length square root it
edited:
I'll show you how to loop through the array and everything is pretty much this same step just with a different calculation.
// calculating mean. int total = 0; for(int i = 0; i < array.length; i++){ total += array[i]; // this is the calculation for summing up all the values } double mean = total / array.length;
edit2:
After reading your code, the part you are doing wrong is that you are not looping through the values and subtracting it with average correctly.
aka this part.
eleven = average_total - mean;
eleven = Math.pow(average_total,average_total);you need to do this.
for(int i = 0; i < array.length; i++){ array[i] = Math.pow((array[i]-mean),2) }
essentially you need to change every value in the array with newvalue = oldvalue - mean(average).
then calculate the sum... then square root that.
这篇关于如何使用JAVA来计算标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!