Sabtu, 08 Oktober 2011

0 Regresi Linier Sederhana


#include
#include
#include

void main(){
int jumlah_data;
float jmlh_x,jmlh_y;
float jmlh_xy,jmlh_x2,jmlh_y2;
float rata_x,rata_y,a,b;
double r,r2;
int data_x[100], data_y[100];
jmlh_x=0; jmlh_y=0; jmlh_xy=0;
jmlh_x2=0; jmlh_y2=0;
cout<<"Masukkan jumlah data yang ingin Anda inputkan : ";
cin>>jumlah_data;
for(int i=0;i
cout<<"x ke [ "<<<" ] : ";cin>>data_x[i];
cout<<"y ke [ "<<<" ] : ";cin>>data_y[i];
}
clrscr();
cout<<"====================================";
cout<<"\ndata x \tdata y \tjmlh x \tjmlh y \tjmlh x2”;
cout<<” \tjmlh y2 \tjmlhxy";
for(int j=0;j
jmlh_x=jmlh_x+data_x[j];
jmlh_y=jmlh_y+data_y[j];
jmlh_xy=jmlh_xy+(data_x[j]*data_y[j]);
jmlh_x2=jmlh_x2+(data_x[j]*data_x[j]);
jmlh_y2=jmlh_y2+(data_y[j]* data_y[j]);
cout<<"\n"<<<"\t"<<<"\t"<<<"\t"<<<"\t"<<<"\t\t"<<<"\t\t"<<<"\n============================\n";
rata_x=jmlh_x/jumlah_data; rata_y=jmlh_y/jumlah_data;
b=(jumlah_data*jmlh_xy-(jmlh_x*jmlh_y))/(jumlah_data*jmlh_x2-(jmlh_x*jmlh_x));
a=rata_y-(rata_x*b);
r=(jumlah_data*jmlh_xy-(jmlh_x*jmlh_y))/((pow((jumlah_data*jmlh_x2-(jmlh_x*jmlh_x)),0.5)) *(pow((jumlah_data*jmlh_y2-(jmlh_y*jmlh_y)),0.5)));
r2=r*r;
cout<<"\n PERSAMAAN REGRESI LINIER";
cout<<" \n y = "<<<" + "<<<"x";

About the Author

I'm Author description here. Go to Blogger edit html and find these sentences. Now replace these sentences with your own descriptions. Subscribe to Our Feed and Follow Me on Twitter My user

    Other Recommended Posts

0 komentar:

Posting Komentar

 
back to top