Clear Filters
Clear Filters

ksdensity function for pdf estimation

4 views (last 30 days)
yasser
yasser on 14 May 2014
Answered: yasser on 14 May 2014
i feed some data to ksdensity but i got a gaussian pdf with peak greater than 1 how is that

Answers (2)

David Sanchez
David Sanchez on 14 May 2014
As you can see in the ksdensity documentation, depending n how you use the function, there is nothing abnormal with your result:
From documentation: Generate a mixture of two normal distributions, and plot the estimated inverse cumulative distribution function at a specified set of values:
x = [randn(30,1); 5+randn(30,1)];
yi = linspace(.01,.99,99);
g = ksdensity(x,yi,'function','icdf');
plot(yi,g);
Paste the code you are using in order to provide a good solution to your question.
  1 Comment
yasser
yasser on 14 May 2014
let num =100
if true function [] =dist_vs_code_rate_non_negl_interf(num) %clear; disp('dist_vs_code_rate_non_negl_interf') n=6; %#of antenna fc=1700*1e6; %carrier freq for lte % BW=1.25*1e6; %operating freq range for narrowband lte could also be 2.5MHZ % fs=3*BW; %sampling freq c=3e8; %speed of light lambda=c/(fc); d=0.5*lambda; %inter antenna separation k=1; %#of usrs %num_pkts = 10; num_pkts=num noise_var_pre=1;
% obs_per=1; %observation period % t=0:1/fs:obs_per-1/fs; % no_samples=length(t); %is fs*obs_per
theta_test = [30]*pi/180; % Test vector of input azimuthiz theta values
A=(exp((transpose(-i*2*pi*d*[0:n-1])*sin(theta_test)/lambda))); %true steering mat for DOA
fft_size=128; %narrow band of lte
code_rate_pre=0.75; code_rate_post=0.5; code_rate_chk=0.5;
M=64;
no_samples_pre=.75*fft_size*log2(M)*code_rate_pre; no_samples_post=.75*fft_size*log2(M)*code_rate_post; no_samples_chk=.75*fft_size*log2(M)*code_rate_chk;
noise=randn(n,1.25*fft_size)*sqrt(1/2)+i*randn(n,1.25*fft_size)*sqrt(1/2); %Uncorrelated noise
loop=1;
for j=1:loop
%pre and negligable case
for m=1:num_pkts
sig=randi([0 1],no_samples_pre,1);
data=transpose(sig);
coded_data =convolution(data,code_rate_pre,10); %not built in fn in matlab code rate 3/4
% Create a rectangular 64-QAM modulator System object with bits as inputs and Gray-coded signal constellation
qamModulator = comm.RectangularQAMModulator(M,'BitInput',true);
% Rotate the constellation by pi/4 radians
qamModulator.PhaseOffset = pi/4;
% Modulate and plot the data
prechange = step(qamModulator, transpose(coded_data));
pre_ofdm=fft_size*ifft(prechange,fft_size);
% Adding Cyclic Extension
cext_pre=zeros(fft_size+0.25*fft_size,1);%ofdm symb is .25*fft_size(GI)+fft_size(data)
cext_pre(1:.25*fft_size)=pre_ofdm(fft_size-0.25*fft_size+1:end);
for k=1:fft_size
cext_pre(k+.25*fft_size)=pre_ofdm(k);
end
X_pre=A*transpose(cext_pre)+noise;
R_pre=X_pre*X_pre'/size(X_pre,2);
b_pre(:,:,m)=R_pre;
end
%change code rate
for m=1:num_pkts
sig_post=randi([0 1],no_samples_post,1);
data=transpose(sig_post);
coded_data =convolution(data,code_rate_post,10); %not built in fn in matlab code rate 1/2
% Create a rectangular 64-QAM modulator System object with bits as inputs and Gray-coded signal constellation
qamModulator = comm.RectangularQAMModulator(M,'BitInput',true);
% Rotate the constellation by pi/4 radians
qamModulator.PhaseOffset = pi/4;
% Modulate and plot the data
post_interf = step(qamModulator, transpose(coded_data));
post_interf_ofdm=fft_size*ifft(post_interf,fft_size);
% Adding Cyclic Extension
cext_post=zeros(fft_size+0.25*fft_size,1);%ofdm symb is .25*fft_size(GI)+fft_size(data)
cext_post(1:.25*fft_size)=post_interf_ofdm(fft_size-0.25*fft_size+1:end);
for k=1:fft_size
cext_post(k+.25*fft_size)=post_interf_ofdm(k);
end
X_post_interf=A*transpose(cext_post)+noise;
R_post_interf=X_post_interf*X_post_interf'/size(X_post_interf,2);
b_post(:,:,m)=R_post_interf;
end
%chk phase
for m=1:num_pkts
sig_chk=randi([0 1],no_samples_chk,1);
data=transpose(sig_chk);
coded_data =convolution(data,code_rate_chk,10); %not built in fn in matlab code rate 1/2
% Create a rectangular 64-QAM modulator System object with bits as inputs and Gray-coded signal constellation
qamModulator = comm.RectangularQAMModulator(M,'BitInput',true);
% Rotate the constellation by pi/4 radians
qamModulator.PhaseOffset = pi/4;
% Modulate and plot the data
post_chk = step(qamModulator, transpose(coded_data));
post_interf_ofdm_chk=fft_size*ifft(post_chk,fft_size);
% Adding Cyclic Extension
cext_chk=zeros(fft_size+0.25*fft_size,1);%ofdm symb is .25*fft_size(GI)+fft_size(data)
cext_chk(1:.25*fft_size)=post_interf_ofdm_chk(fft_size-0.25*fft_size+1:end);
for k=1:fft_size
cext_chk(k+.25*fft_size)=post_interf_ofdm_chk(k);
end
X_post_chk=A*transpose(cext_chk)+noise;
R_post_interf_chk=X_post_chk*X_post_chk'/size(X_post_chk,2);
b_post_chk(:,:,m)=R_post_interf_chk;
end
%calc dist
for m=1:num_pkts
pre_post_dist(m)=(norm(10*log10(eig(b_post(:,:,m),b_pre(:,:,m)))));
post_chk_dist(m)=(norm(10*log10(eig(b_post(:,:,m),b_post_chk(:,:,m)))));
end
[f1 xi]=ksdensity(pre_post_dist);
[f2 xii]=ksdensity(post_chk_dist);
plot(xi,f1);
grid on;
hold on
plot(xii,f2,'r');
legend('pre-post' , 'post-chk');
end
end

Sign in to comment.


yasser
yasser on 14 May 2014
please some one post an explanation i need it urgently

Categories

Find more on Propagation and Channel Models in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!