【正文】
符的個數(shù)n(i) 算出每種字符的概率p(i) ③ ④ 由信源熵計算公式計算出信源熵 ⑤ 香農(nóng)編碼開始輸入概率矩陣將概率由大到小排列計算累加概率和概率的個數(shù)根據(jù)公式調(diào)用函數(shù)計算碼長用循環(huán)程序編碼并調(diào)整輸出格式 計算信源熵和編碼效率輸出信源熵、編碼效率和碼字結束 費諾編碼開始輸入概率矩陣將概率由大到小排列計算累加概率和概率的個數(shù)在兩組概率之和近似相等的條件下將概率分為兩組,各賦予0,1兩個碼元將每一大組的的概率重復上一步操作,直到每組只剩一個概率 用循環(huán)程序編碼并調(diào)整輸出格式計算信源熵和編碼效率輸出信源熵、編碼效率和碼字結束四、 程序及結果 統(tǒng)計信源熵的Matlab程序function h=entropy(p)clcfid=fopen(39。39。,39。r39。)。%打開txt文件[ex,num]=fscanf(fid,39。%c39。,inf)%讀取二進制文件的數(shù)據(jù),并將數(shù)據(jù)存入矩陣str1=lower(ex)%將字符串中的大寫字母轉換成小寫字母sort_str1=sort(str1)。%按照字符的ASCII值對字符串排序j=1。for i=1:length(sort_str1)1%計算出字符串的種類 if strcmp(sort_str1(i),sort_str1(i+1))~=1%比較兩個字符串是否完全相等,相等是1,否則0 j=j+1。 str2(j)=sort_str1(i)。 end str2(j+1)=sort_str1(i+1)。endfor i = 1:length(str2)%length函數(shù)獲取字符串長度 str_num =strfind(sort_str1,str2(i))。%strfind(S1,S2):尋找S2是否匹配S1,并返回S2的位置 count1(i) = length(str_num)。endstr2count=count1(3:end)p=count./sum(count)sum(p.*log2(p))%計算信源熵待讀取的英文:The Pressure of Graduate StudentsNow I am a post graduate student, I will graduate next year, so I start to find jobs recently, I feel so much pressure, though I have good education, I still get rejection from the panies. The pressure of graduate students are so heavy, the petition is so fierce that many students can’t get the ideal jobs. They should adjust their strategies.The pressure of graduate students is so heavy. On the one hand, they don’t have experience, so they don’t know how to get the job interview and miss many chances. On the other hand, there are more and more students have high education, some have received higher education, some have studies abroad which make their resumes stand out. Those average students don’t have advantages over