欢迎来到天天文库
浏览记录
ID:25972953
大小:50.03 KB
页数:3页
时间:2018-11-24
《信息量及信道容量的计算》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#includeusingnamespacestd;intmain(){inti,j,k,m,n;charr;charA='Y',B='N';doublex[20],p[12][12],q[12][12],y[20];cout<<"输入信源x的个数N=";cin>>n;cout<<"输入所需信源概率:"<>x[i-1];}cout<<"输入信道矩阵:"<2、n;i++){for(k=1;k<=n;k++){cout<<"请输入P(y"<>p[i-1][k-1];}}//for(;;);//{cout<<"1信源熵2条件熵3联合熵4交互熵"<>m;if(m==1){doubleH=0,h;for(intj=1;j<=n;j++){h=-x[j-1]*log10(x[j-1])/log10(2);H=H+h;}cout<<"信源熵为:"<3、1=0,H2=0,h2=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];//cout<<"联合概率"<<"y"<4、[j-1])/log10(2);H2=H2+h2;}cout<<"条件熵H(Y/X)为:"<5、bleH4=0,h4=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];H4=-q[i-1][j-1]*log10(q[i-1][j-1]/x[i-1])/log10(2);H4=h4+H4;}}cout<<"交互熵I(x;y)=I(y;x)为:"<>r;//if(r==A)//{continue;}//if(r==B)6、//{break;}//}return0;}
2、n;i++){for(k=1;k<=n;k++){cout<<"请输入P(y"<>p[i-1][k-1];}}//for(;;);//{cout<<"1信源熵2条件熵3联合熵4交互熵"<>m;if(m==1){doubleH=0,h;for(intj=1;j<=n;j++){h=-x[j-1]*log10(x[j-1])/log10(2);H=H+h;}cout<<"信源熵为:"<3、1=0,H2=0,h2=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];//cout<<"联合概率"<<"y"<4、[j-1])/log10(2);H2=H2+h2;}cout<<"条件熵H(Y/X)为:"<5、bleH4=0,h4=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];H4=-q[i-1][j-1]*log10(q[i-1][j-1]/x[i-1])/log10(2);H4=h4+H4;}}cout<<"交互熵I(x;y)=I(y;x)为:"<>r;//if(r==A)//{continue;}//if(r==B)
3、1=0,H2=0,h2=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];//cout<<"联合概率"<<"y"<
4、[j-1])/log10(2);H2=H2+h2;}cout<<"条件熵H(Y/X)为:"<
5、bleH4=0,h4=0;for(i=1;i<=n;i++){for(j=1;j<=n;j++){q[i-1][j-1]=p[i-1][j-1]*x[i-1];H4=-q[i-1][j-1]*log10(q[i-1][j-1]/x[i-1])/log10(2);H4=h4+H4;}}cout<<"交互熵I(x;y)=I(y;x)为:"<
6、//{break;}//}return0;}
此文档下载收益归作者所有