내 코드는 표본 편차를 계산할 때 모집단 편차를 계산합니다. 두 수식을 비교하고 계산을 변경했지만 아무 것도 작동하지 않는 것 같습니다. 모든 사람의 도움을 받거나 사전에 의견을 보내 주셔서 감사합니다.샘플을 계산하기 위해 내 코드에서 변경해야 할 항목 표준 표준 편차 대신 표준 편차?
public class MeanAndStandardDeviation {
public static void main (String argv []) throws IOException {
BufferedReader stdin =
new BufferedReader (new InputStreamReader (System.in));
NumberFormat nf = new DecimalFormat ("0.00");
nf.setMinimumFractionDigits (2);//Sets Min digits
nf.setMaximumFractionDigits (2);//Sets Max digits
String inputValue;
int count = 0;
//For Loop for count
for(int i = 0; i < count; i++){
count++;
}
double varianceFinal = 0;
List<String> input = new ArrayList<String>();//String ArrayList
List<Double> numbers = new ArrayList<Double>();//Double ArrayList
//While loop that takes in all my input and assigns it to the ArrayLists
//Parameters set for when null is entered and total numbers go over 500
while((inputValue = stdin.readLine()) != null && !inputValue.equals("") && input.size()<500){//Parameters set for when null is entered and total numbers go over 500
input.add(inputValue);
numbers.add (Double.parseDouble(inputValue));
}
System.out.println ("Standard Deviation: " +(nf.format(calcStdDev (numbers, count, varianceFinal))));//Prints the Standard Deviation
}
//StandardDeviation Class
static double calcStdDev (List<Double> numbers, int count, double variance){
variance = 0;
double sum = 0;
for(int i = 0; i < numbers.size(); i++){
sum += numbers.get(i);
variance += numbers.get(i) * numbers.get(i);
count++;
}
double varianceFinal = ((variance/count)-(sum*sum)/(count*count));
return Math.sqrt(varianceFinal);
}
}
내 표준 편차 클래스가 바닥에 있습니다 – swaguire
그냥 레코드 용입니다. 이름 지정에 대한 정확한 설명 : 클래스가 아닌 정적 ** 메소드 **가 두 개 있습니다. – GhostCat
죄송합니다. – swaguire