Dibawah ini akan diuraikan tentang program statistik peluang. Dimana postingan ini adalah hasil tugas daripada mata kuliah statistika. Selamat mencoba. dont affraid to try
#include<iostream.h>
#include<conio.h>
main()
{
float P_B[50],P_AgB[50],B[100],P_AgAB[100];
float P_BigA,P_BigAb,P_BigAc,P_A;
int i,nS=0;
//input
for(i=1;i<=3;i++)
{
cout<<"banyak nilai (B"<<(i)<<") ; ";
cin>>B[i];
nS=nS+B[i];
}
//cetak dalam bentuk array
clrscr();
cout<<"\n DALAM BENTUK TABEL\n";
cout<<"=========================\n";
cout<<" B1 | B2 | B3 |jumlah||\n";
cout<<"=========================\n";
cout<<"A|";
for(i=1;i<=3;i++)
{
cout<<" "<<B[i]<<" |";
}
cout<<" "<<nS<<" ||";
cout<<"\n=========================\n\n\n";
//proses mencari peluang terambilnya data B[i]
for(i=1;i<=3;i++)
{
P_AgAB[i]=B[i]/nS;
}
P_A=0;
for(i=1;i<=3;i++)
{
P_AgB[i]=P_AgAB[i]/P_AgAB[i];
P_B[i]=B[i]/nS;
P_A=P_A+(P_B[i]*P_AgB[i]);
}
//proses pencarian peluang bersyarat
P_BigA= (P_B[1]*P_AgB[1])/P_A;
P_BigAb= (P_B[2]*P_AgB[2])/P_A;
P_BigAc= (P_B[3]*P_AgB[3])/P_A;
cout<<"a] Peluang bersyarat kejadian B1 terhadap A (B1/A)= "<<P_BigA<<endl;
cout<<"b] Peluang bersyarat kejadian B2 terhadap A (B2/A)= "<<P_BigAb<<endl;
cout<<"c] Peluang bersyarat kejadian B3 terhadap A (B3/A)= "<<P_BigAc<<endl;
getch();
}
Semoga bermanfaat untuk anda. :)
This entry was posted on 00.30 and is filed under
C++ Statistik Peluang
. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
0 komentar: