우리는 수업 중 프로젝트에 대해 선형 회귀를 수행하고 있습니다. 함수를 작성해야합니다. 정적 캐스팅 및이 "int n"을 double로 변경하는 다른 방법을 시도하여 오류가 발생하지 않습니까? 아니면 완전히 잘못된 생각을하고 있습니까?
함수
void linear_regression(double x[], double y[], int n,
double *slope, double *y_int)
{
double sum_x, sum_y, sum_x_Squared, sum_Squared_x, product_x_y;
double m = *slope, b = *y_int;
sum_x = sum_array(x, n);
sum_y = sum_array(y, n);
sum_Squared_x = sum_square_array(x, n);
sum_x_Squared = sum_array(x, n) * sum_array(x, n);
product_x_y = sum_product_of_arrays(x, y, n);
//I'm getting an error on the next statement, about the n
m = ((sum_x * sum_y) - (n * sum_product_of_arrays)) /
((sum_x_Squared) - (n * sum_Squared_x));
b = ((sum_y - (m * sum_x))/(n));
return;
}
에러 메시지
Invalid operands of types 'int' and 'double(double*, double*, int)' to
binary operator.
에서가 n * sum_product_of_arrays
, sum_product_of_arrays
당신이 얻기 위해 호출하는 기능입니다 product_x_y
. 사용하려고 했습니까 product_x_y
?
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다