about the rate distortion function

9 vues (au cours des 30 derniers jours)
Genus
Genus le 15 Mai 2013
I am having problems with the rate distortion function implemented in matlab. im recieving an error message of
Error in ==> blahut at 9
m=sum(p.*Y); %mathematical expectation of Y
Error in ==> Rate_distort at 18
[R,SNR] = blahut(p,nl,Y');
here is the blahut mfile
function [R,SNR] = blahut(p,nl,Y)
%This function computes one point of H(D) for given lambda
%D is distortion in dB
%p is probability distribution of input sequence
%nl=-lambda
%Y is approximating set
m=sum(p.*Y); %mathematical expectation of Y
sigma2=sum(p.*(Y-m).^2);%variation of Y
N=length(p);
ry=p; %initialization of distribution r(y)
diff=(diag(Y)*ones(N,N)-ones(N,N)*diag(Y)).^2;
A=2.^(-nl*diff);
D=diff.*A;
flag=1;
%%%%%%%%Iterations%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
while flag==1
v=ry*A'; %sum_y r(y)2^(lambda d(x,y))
P=p./v;%p(x)/sum_y r(y)2^(lambda d(x,y))
c=P*A; %c(y)
ry=ry.*c; %modified distribution
%%%%%%%%Computing thresholds%%%%%%%%%%%%%%%%%%%%
TU=-sum(ry.*log2(c));
TL=-max(log2(c));
error=TU-TL;
%%%%%%%%%%%%%Stopping rule%%%%%%%%%%%%%%%%%%%%%
if error < 10^(-3)
flag=0;
end
d=P*D*ry'; %distortion
rate=-nl*d-log2(v)*p'-TL; %rate;
end
R=rate;
SNR=10*log10(sigma2/d);%distortion in dB
Here is my test file with components
N takes in values from 10:10:50
P is the probability distribution in the form of the binomial distribution
theta takes in value in the interval [0 1]
also theta is specified for theta = i/n with i = 0,1,....,n
%%Values for n
n=50;
theta=0:0.5;
nVec=10:n;
for jdx=1:length(theta)
for kdx=1:length(nVec)
p(jdx,kdx)=nchoosek(n,nVec(kdx))*((theta)^nVec(kdx))*((1-(theta))^(n-nVec(kdx)));
end
end
%%specifications for rate distortion
nl = 0.1;
Y = [0 1; 1 0];
%%Blahut algorithm for rate distortion calculation
[R,SNR] = blahut(p,nl,Y');
When I type in my disitortion matrix for Y, this is where Im encountering the error
Error in ==> blahut at 9
m=sum(p.*Y); %mathematical expectation of Y
end
I also need to know how to plot the Distortion vs R(D).
Please help with any tips. Thank you very much if true
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 15 Mai 2013
Walter Roberson
Walter Roberson le 19 Mai 2013
There would be an error message just before that. For example it might say something like "matrix dimensions must agree". We need to see that message.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by