Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Replies: 49   Last Post: Mar 4, 2016 2:43 AM

 Messages: [ Previous | Next ]
 sesham srinu Posts: 14 Registered: 9/13/09
Posted: May 8, 2010 12:51 PM

"Vivi Sera" <vivi.seraphic@gmail.com> wrote in message <hrmljm\$htd\$1@fred.mathworks.com>...
> I am doing a term project in spectrum sensing as well, probably focus on cooperative schemes, but will start with the conventional one, such as energy detection, matched filter, etc etc. If any of you have some good scripts for me to start off, would it be okay for you to share with me, please? I really appreciate it!
hai iam sesham srinu from university of hyderabad,india
%Entropy estimation of a stochastic signal for primary user detection for the matched filter case

clear all;clc;

%**************************************Input parameters**********************************************************************************

b = [ 1 0 0 1 1]; % Input bit stream

N=[16 32 64];

for j=1:length(N)
snr_db=0:1:20;
g=length(snr_db);
%*************************************BPSK signal generation, Matched filtering and Sampling********************************************
for z=1:length(snr_db)

[signal]=bpsk(b); %BPSK signal generation
[s_matched signal_noise noise]=match(signal_fad,snr_db(z)); % matched filtered output of Qpsk signal

%************************************Entropy anlaysis after matched filter output is sampled********************************************

L=N(j); %No.of bins

s=s_matched(1:N(j)); % N no.of samples Sampled output of matched filter

x=[ ];
x=s(1:N(j)); %block of N samples of matched filter to make decision

noise=noise(1:N(j));

K=4;
sq=sum(x.^2)/N(j);
sigma = sqrt(sum(x.^2)/N(j));
%**********************************checking for chebyeshev inequality*******************************************************************
count=0;
for i=1:N(j)
if(abs((x(i)-mean(x)))>(K*sigma))
count=count+1;

else
count=count;
end
end

if ((count/N(j))<= (1/(K^2)))

%display('Design value of K is correct ');

else
%display('Design value of K is incorrect and try for another value');

end

% %***********************************Histogram of x**************************************************************************************
v1=(2*K*sigma)/(L); % Width of each bin
v=-K*sigma:v1 :K*sigma; % a vector specifying the centres of bins from where to start and stop.

%***********************************Checking for no.of values of x fallong inside the kth bin********************************************

pa11=0;
pa01=0; y1=0;e(z)=0;
for k=1:L;

number_samples=0;

lk(k)=v(k)-(v1/2);
lkplus1(k)=v(k)+(v1/2);

for i=1:N(j)
if((lk(k)<x(i))& (x(i)<lkplus1(k)))
number_samples=number_samples+1;
else
number_samples=number_samples+eps;
end
end

nk=number_samples;

y1=y1+number_samples;
%----------------------------------------Entropy caculation------------

if(nk~=0)
nk=nk;
else
nk=nk+eps;

end
p(k) = -((nk/N(j))*log2(nk/N(j)));
e(z)= e(z)+p(k) ; %Entropy estimate

%********************************************computing pk(a)********************************************************************************
a1=snr_db(z);

a0=0;

pk1=0;pk0=0; M=2; u(1)=1;u(2)=-1;
for m=1:M
h1(m)=0;h2(m)=0;h3(m)=0;h4(m)=0;

h1(m)=(lk(k)-u(m)*sqrt(a1/(1+a1)))*(1+a1);
h2(m)=(lkplus1(k)-u(m)*sqrt(a1/(1+a1)))*(1+a1);
h3(m)=(lk(k)-u(m)*sqrt(a0/(1+a0)))*(1+a0);
h4(m)= (lkplus1(k)-u(m)*sqrt(a0/(1+a0)))*(1+a0);

pk1=pk1+[[qfunc(h1(m))]-[qfunc(h2(m))]];
pk0=pk0+[[qfunc(h3(m))]-[qfunc(h4(m))]];

end

pka1= (1/M)*pk1+eps;
pka0= (1/M)*pk0+eps;

%*********************************************computing log-likelihood ratio***************************************************************

pa11=pa11+(nk/N(j))*[log2(pka1)-log2(pka0)];

end

le(z)=pa11;%Log-likelihood ratio of entropy
end

e1((j+(j-1)*20):j*21)=e;
le1((j+(j-1)*20):j*21)=le;
end

plot(snr_db,e1(1:21),'-b*',snr_db,e1(22:42),'-ro',snr_db,e1(43:63),'-g.');
xlabel('SNR in db');
ylabel('Entropy');
title('Normal entropy');
h2=legend('N=16 BPSK','N=32 BPSK','N=64 BPSK',1);

figure
plot(snr_db,le1(1:21),'-b*',snr_db,le1(22:42),'-ro',snr_db,le1(43:63),'-g.');
xlabel('SNR in db');
ylabel('Log-likelihood Entropy');
title('log-likelihood entropy')
h2=legend('N=16 BPSK','N=32 BPSK','N=64 BPSK',1);

Date Subject Author
8/8/08 nancy
8/19/08 Guido Gioberto
8/21/08 nancy
9/5/08 nancy
10/15/08 rizwan
10/27/09 Johnas
12/7/09 Luca
1/16/10 Md. Rakib
3/7/10 khalil ajmi
2/10/11 amber
5/8/10 sesham srinu
10/20/08 chen ximei
10/20/08 chen ximei
1/11/09 gmt mathew
9/8/09 Brice
1/22/12 vengat
3/12/12 gopinath R
3/4/16 June1992
3/8/10 Jorian
2/12/09 Mirage Bhatti
5/8/10 sesham srinu
6/2/10 samee Rehman
2/23/09 Soyoung LEe
2/23/09 talhazahir@gmail.com
4/6/09 mary
7/15/09 kk muthu
7/15/09 Alicia Cheng
10/22/09 ehab elshaer
5/3/10 Vivi Sera
5/3/10 Vivi Sera
5/8/10 sesham srinu
1/7/12 vengat
1/7/12 vengat
1/8/12 mobien
11/24/12 jenkinwinston.j2011@vit.ac.in
7/16/10 her linda
7/16/10 Steven Lord
10/8/10 mike mekkanen
11/14/10 shamser
11/14/10 shamser
11/14/10 shamser
11/14/10 shamser
11/25/10 ravi sharan
11/25/10 Walter Roberson
5/25/11 Sindiso Nleya
9/8/12 jaya pavi
11/21/12 amit
12/5/12 ABDUL