i][j]*log(1/N[i][j]);?}}//信道疑义度floatHxy=0;?for(i=0;i<27;i++) for(j=0;j<27;j++) { Hxy=Hxy+M[i][j]; } printf("信道疑义度为:\n"); printf("%f",Hxy);?printf("\n"); printf("\n");//计算熵?fp=fopen("file.txt","r");?if(fp==NULL)?{ printf("不能打开文件\n");?exit(0);?};?while((c=fgetc(fp))!=EOF)?{ if(c>='a'&&c<='z') num[c-97]++; elseif(c>='A'&&c<='Z') num[c-'A']++; if(c==32) { space++; };?}?t=0;shang=0;?for(i=0;i<=25;i++) t=t+num[i];?t+=space;?printf("各字母的概率为:\n");?for(i=0;i<=25;i++)?{ f[i]=num[i]/t; if(f[i]!=0) printf("%c,%f",97+i,f[i]);?}?floatps;?printf("space,%f\n",ps=space/t);?for(i=0;i<=25;i++)?{?if(f[i]!=0)shang=shang-f[i]*log(f[i]);?}?if(ps!=0) shang-=ps*log(ps);?printf("\n信息熵=%f",shang);?fclose(fp);?printf("\n");?floatI;?I=shang-Hxy;?printf("\n");?printf("平均互信息I(X;Y)为:\n");?printf("%f\n",I);?printf("\n");}