📄 ge_cap.m
字号:
function y = ge_cap(b,g,pb,pg,iter)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This function calculates the capacity of a Gilbert-Elliott% channel according to the method of Mushkin and Bar-David (1989).%% This implementation is Copyright (C) 2003 by A. W. Eckford,% and is released into the public domain as long as this% entire comment is preserved in the source.% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The function takes five parameters:% b - is the transition probability from the good to bad state% g - is the transition probability from the bad to good state% pb - is the inversion probability in the bad state% pg - is the inversion probability in the good state% iter - the number of iterations to use in the calculation% (the exact capacity is calculated in the limit as iter -> infinity,% so make this as large as is practical)q = zeros(1,1001);inc = (pb-pg)/1000;tq = pg:inc:pb;avg_coord = round((((b*pb + g*pg)/(b+g)) - pg)/inc) + 1;q(avg_coord) = 1/inc;mu = 1-g-b;for c = 1:iter q1 = zeros(1,1001); for beta = pg:inc:pb beta_coord = round((beta-pg)/inc) + 1; alpha0 = pg + b*(pb-pg) + mu*(beta - pg)*(1-pb)/(1-beta); alpha0_coord = round((alpha0 - pg)/inc) + 1; alpha1 = pg + b*(pb-pg) + mu*(beta - pg)*pb/beta; alpha1_coord = round((alpha1 - pg)/inc) + 1; q1(alpha0_coord) = q1(alpha0_coord) + (1-beta)*q(beta_coord); q1(alpha1_coord) = q1(alpha1_coord) + beta*q(beta_coord); end q = q1;endtrapz(tq,q);H = -1*tq.*log2(tq) - (1-tq).*log2(1-tq);EH = trapz(tq,H.*q);y = 1-EH;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -