회귀방정식C언어로짜는데main부분을어떻게해야할지모르겠어요 도와주세요 ㅠㅠ
지은
질문 제목 : 질문 요약 :
고수님들도와주세요 ㅠㅠ이프로그램의main부분은 어떻게해야하나요?ㅜㅜ
질문 내용 :
void regress(data, num)
float *data;
int num;
{
float a, b, x_avg, y_avg, temp, temp2;
float data2[280], cor;
float std_dev();
int t, min, max;
char s[80];
/* find mean of y*/
y_avg=0;
for(t=0; tnum; ++t)
y_avg+=data[t];
y_avg/=num;/*now find b */
temp=0; temp2=0;
for(t=1; t=num; ++t){
temp+=(data[t-1]-y_avg)*(t-x_avg);
temp2+=(t-x_avg)*(t-x_avg);
}
b=temp/temp2;
/*now find a */
a=y_avg-(b*x_avg);
/* now compute coefficient of correlation */
for(t=0; tnum; ++t)
data2[t]=t+1;/*load x axis */
cor=temp/(num);
cor=cor/(std_dev(data, num)*std_dev(data2, num));
printf(regression equation is: Y = %f + %f * X\n, a,b);
printf(Correlation Coefficient: %f\n, cor);
}