You are on page 1of 18

ELECTRICAL ENGINEERING DEPARTMENT, KFUPM

MIMO Capacity and gain of


Optimal power allocation
using Water-Filling
algorithm
EE 575 Information Theory
Assignment # 3

Submitted by:
Raza Umar
Student ID: g200905090
5/23/2010

In this assignment, capacity of parallel Gaussian channels has been compared for equal power allocation
and optimal power allocation based on water-filling algorithm. Mean capacity comparisons,
Complementary CDF comparisons and Outage probability comparisons have been analyzed for SISO,
SIMO, MISO, MIMO and MIMO using Water-Filling power allocation.

Table of Contents
Problem 1: Parallel Gaussian Channels .................................................................................................... 4
Part (1a) Total capacity of parallel channels for equal power distribution........................................... 4
Part (1b) Water-filling algorithm ........................................................................................................ 5
Part (1c) Total capacity of parallel channels for optimal power distribution ....................................... 5
Problem 2 + Problem 3: MIMO Capacity + Water filling for 4x4 MIMO Channel ....................................... 6
Part (2a+3a) Mean capacity comparisons for MIMO channels ............................................................ 6
Part (2b+3b) Complementary CDF comparison for flat fading channels .............................................. 8
Part (2c+3c) Outage probability vs. SNR for flat adding channels ........................................................ 9
Appendix A ............................................................................................................................................ 10
Appendix B ............................................................................................................................................ 13

Problem 1: Parallel Gaussian Channels


Given received signal:







    
 







Where,


1

0
  ~ 0, 

0

0

0
7
0
0

0
0
5
0

0
0

0
3

Total Power transmission=Pt=20


Part (1a) Total capacity of parallel channels for equal power distribution

As we have 4 parallel channels


M=4=Nt=Nr
N1=1, N2=7, N3=5, N4=3
For equal power distribution:
 
8

 20

 5,   1,2,  ,   4

4


max

#$%&': )$%* '+ ,)8

. $/; 1 '

1

1

  2 log  61
7  log  : 61
7  2.8888 =>?/A
2

2

9

9

Part (1b) Water-filling algorithm

Matlab implementation of Water filling algorithm is available in Appendix A.


Part (1c) Total capacity of parallel channels for optimal power distribution

For, N1=1, N2=7, N3=5, N4=3


Water level obtained from Matlab code = v=9 &
P1=8, P2=2, P3=4, P4=6

using, >9$BCD* 'E

With optimal power allocation;


F#
Hence,

1

 2 log  61
7  2.9827 =>?/A
2

9

H>HIJ KHL  F# M   0.0939 =>?/A

Problem 2 + Problem 3: MIMO Capacity + Water filling for 4x4 MIMO


Channel
Matlab Implementation for MIMO Capacity and Water filling for 4x4
MIMO Channel is available in Appendix B.

Part (2a+3a) Mean capacity comparisons for MIMO channels

Water filing Capacity Gain

WF gain in capacity
0.9
0.8

WF gain in bps/Hz

--->

0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-10

-5

10
SNR in dB

15
--->

20

25

30

Part (2b+3b) Complementary CDF comparison for flat fading channels

Complementary CDF comparisons (vs capacity) at SNR=10dB


1
4x4 MIMO WF
4x4 MIMO
4x1 MISO
1x4 SIMO
1X1 SISO

0.99

--->

0.97

1 - Outage Probability

0.98

0.96
0.95
0.94
0.93
0.92
0.91
0.9

5
Mean Capacity bps/Hz

10
--->

15

Part (2c+3c) Outage probability vs. SNR for flat adding channels

Outage probability vs SNR for 4 bps/Hz

10

-1

10

Outage Probability

-2

10

-3

10

4x4 MIMO
4x1 MISO
1x4 SIMO
1X1 SISO
4x4 MIMO WF

-4

10

-5

10

10
SNR in dB

12
--->

14

16

18

20

Appendix A
%% Function: wfill
% This routine optimally allocates the power among "m" channel using water
% filling algorithm
% Input:
% 1. Pt: Total Power budget
% 2. m: Total available parallel channels
% 3. N: Un-correlated Noise variances ( a row vector of lenght m)
% Output:
% 1. v: water level
% 2. P: power levels corresponding to "m" (arranged in the same order as
% N) according to water filling algo.
function [v P] = wfill(Pt,m,N) % Optimum power allocation function
res=1; % resolution of step size
P=zeros(1,m); % initialize transmitted power over each parallel channel to be
0
[N_sorted,index]=sort(N);
% Noise power sorted in ascending order
step=(N_sorted(2)-N_sorted(1))/res;
N_sorted_temp=N_sorted;
for p=1:length(N_sorted_temp)-1
if ((max(N_sorted_temp)-min(N_sorted_temp))>Pt)
m=m-1;
N_sorted_temp=N_sorted_temp(1:end-1);
end
end
if step>Pt/2
step=Pt/2;
end
if step<0.001
step=.001;
end
j=0;
k=0;
epsilon=1e-5;
epsilon2=1e-4; %threshold for discrepancies in water level over different
channels
i=1;
z=0;
q=2;
step_old=0;
for iter=1:1e6*res
if(sum(abs((N_sorted(1).*ones(1,m))-N_sorted(1:m))<1e-6)==m && (sum(P)<
Pt))
step=(Pt-sum(P))/m;
N_sorted(1:m)=N_sorted(1:m)+step;
P(1:m)=P(1:m)+step;
break;
end

N_sorted(i)=N_sorted(i)+step;
P(i)=P(i)+step;
if(sum(abs((N_sorted(1).*ones(1,q))-N_sorted(1:q))<1e-6)==q && (sum(P)<
Pt))
if q==(length(N))
step=2*step;
end
if(q<m)
step=N_sorted(q+1)-N_sorted(q);
q=q+1;
end
end
if (j>0 && step_old>step)
step =step_old;
j=0;
end
if (sum(P)>Pt)
k=k+1;
N_sorted(1:i)=N_sorted(1:i)-step;
P(1:i)=P(1:i)-step;
% find how many channels(out of m) are at same level
check =
abs(N_sorted-N_sorted(1).*ones(1,length(N)))<epsilon;
check2=find(check);
i=max(check2);
step=(Pt-sum(P))/(i);
N_sorted(1:i)=N_sorted(1:i)+step;
P(1:i)=P(1:i)+step;
end
if(k>2)
display(['Warning: Power alltoment exceeding budget ',num2str(k),'rd
time']);
sum(P)
end
if i<length(N)
if((N_sorted(i)-N_sorted(i+1))>epsilon)
%if water has gone above the next level, set the step such that when water
%is added to the next level, its level becomes the same as previous level
if ((z~=1)&&(step~=N_sorted(i)-N_sorted(i+1)))
step_old=step;
step=N_sorted(i)-N_sorted(i+1);
z=0;
end
if (step< 0.001)
j=1;
end
i=i+1;
else if i>1 % if water is below next entry of N,
%re-initiazlize it to point at 1st entry and start re-filling water
i=1;
end
end
else
% if i is pointing at the last entry of N, re intialize it to
point at 1st entry

i=1;
end
if (abs(sum(P)-Pt) < epsilon2)
if i>1&&(N_sorted(i) < N_sorted(i-1))
N_sorted(1:i-1)=N_sorted(1:i-1)-step;
P(1:i-1)=P(1:i-1)-step;
step=(step*(i-1))/i;
N_sorted(1:i)=N_sorted(1:i)+step;
P(1:i)=P(1:i)+step;
j=0;
i=1;
z=1;
end
end
if (abs(sum(P)-Pt) < epsilon2)
flag_vector2=abs(N_sorted(1).*ones(1,length(find(P)))N_sorted(1:length(find(P))))< epsilon2.*ones(1,length(find(P)));
flag_vector=find(flag_vector2-ones(1,length(find(P))));
if isempty(flag_vector)
break;
end
end
if iter>1000
display('Warning: wf took more than 1000 iterations');
end
end
v= N_sorted(1); % water level
N_sorted;
N;
P=P(index);
if(abs(sum(P)-Pt) > epsilon2)
display('Warning: Power above budget');
end

Appendix B
%% Main function to calculate MIMO channel capacity and associated figures
%% of merit like complementary CDF & Outage probability
% Objective: (1)This function compares Mean channel capacity for different
% MIMO realizations (SISO, SIMO,MISO, MIMO)as a function of SNR
% (2) compares complementary CDF for different MIMO realizations
% (SISO, SIMO,MISO, MIMO)as a function of capacity in bps/Hz
% (3) compares Outage probability for different MIMO realizations
% (SISO, SIMO,MISO, MIMO)as a function of SNR
% Author: Raza Umar as part of EE 575 Information Theory Assignment
% Date: May 08, 2010
%% >>>>>>>>>>>>>>>>>>>>>>>> ... CLEANING ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
close all;
clear all;
clc;
%% >>>>>>>>>>>>>>>>> ... SIMULTAION PARAMS ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<
SNR_dB=-10:30;
SNR=10.^(SNR_dB./10);
ch_realizations=10000; % Monte Carlo sim. of 10,000 channel realizations
c_outage=4;
epsilon=1e-6;
%% >>>>>>>>>>>>>>>>>>>>>>> ... SISO ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% initialization and param setting
c11_i=zeros(length(SNR),ch_realizations);
c11=zeros(length(SNR),1);
% matrix initializations to avoid matrix growing inside loop
% Mean channel capacity calculations
for i1=1:length(SNR)
SNR_i= SNR(i1); % for one specific value of SNR
h11=1/sqrt(2).*complex(randn(1,ch_realizations),randn(1,ch_realizations));
% complex normal r.v. with var=1/2 per dim.
h11_mag_sq=abs(h11).^2;
c11_i(i1,1:ch_realizations)=log2(1+SNR_i.*h11_mag_sq); % instantaneous
cap.
c11(i1)=mean(c11_i(i1,:)); % mean capacity
end
%complementary CDF at SNR=10dB
c11_all=c11_i(21,:); % channel realizations at 10dB SNR
range_11=0:0.1:max(c11_all);
count11=histc(c11_all,range_11);
count11_norm=cumsum(count11)/max(cumsum(count11));
comp_CDF_11=1-count11_norm;
%outage probability
j1= 1;
for i1=find(SNR_dB==2):find(SNR_dB==20)
c11_all=abs(c11_i(i1,:));
range11=0:0.1:max(c11_all);
count11=histc(c11_all,range11);

count11_norm=cumsum(count11)/max(cumsum(count11));
if(isempty(find(abs(range11-c_outage)<epsilon)))
outage11(j1)=1;
else
outage11(j1)=count11_norm(find(abs(range11-c_outage)<epsilon));
end
j1=j1+1;
end
%% >>>>>>>>>>>>>>>>>>>>> ... MIMO (4x4) ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% initialization and param setting
Pt=1; % power budget for MIMO water filling
Nr=4;
Nt=4;
I_Nr=eye(Nr);
c44_i=zeros(length(SNR),ch_realizations);
c44=zeros(length(SNR),1);
% matrix initializations to avoid matrix growing inside loop
% Mean channel capacity calculations
for i1=1:length(SNR)
SNR_i= SNR(i1); % for one specific value of SNR
H_vec=1/sqrt(2).*complex(randn(Nr*Nt,ch_realizations),randn(Nr*Nt,ch_realizat
ions));
% Channel matrix with elements as complex normal r.v. having var=1/2 per
dim.
H=reshape(H_vec,Nr,Nt,ch_realizations);
for i2=1:ch_realizations
H_i=H(1:Nr,1:Nt,i2);
H_H_hermt=H_i*H_i';
arg=I_Nr+ (SNR_i/Nt).*H_H_hermt;
arg2= det(arg);
c44_i(i1,i2)=log2(arg2); % instantaneous cap.
%% alternate implementation to find inst. cap. (using eigen values)
%
lamda=eig(H_H_hermt);
%
arg3=(1+(SNR_i/Nt)*lamda(1))*(1+(SNR_i/Nt)*lamda(2))*(1+(SNR_i/Nt)*lamda(3))*
(1+(SNR_i/Nt)*lamda(4));
%
c442i(i1,i2)=log2(arg3); % instantaneous cap.
%% MIMO water filling
lamda=eig(H_H_hermt);
N=1./(SNR_i.*lamda);
N_wf=N';
[v P_wf]=wfill(Pt,4,N_wf);
arg_wf=(1+P_wf(1)/N_wf(1)).*(1+P_wf(2)/N_wf(2)).*(1+P_wf(3)/N_wf(3)).*(1+P_wf
(4)/N_wf(4));
c44_i_wf(i1,i2)=log2(arg_wf); % instantaneous cap. using wf
%%
end
c44(i1)=mean(c44_i(i1,:)); % mean capacity
c44_wf(i1)=mean(c44_i_wf(i1,:)); % mean capacity
end

%%
%%complementary CDF at SNR=10dB
c44_all=abs(c44_i(21,:)); % channel realizations at 10dB SNR
range_44=0:0.1:max(c44_all);
count44=histc(c44_all,range_44);
count44_norm=cumsum(count44)/max(cumsum(count44));
comp_CDF_44=1-count44_norm;
%%MIMO WF
c44_all_wf=abs(c44_i_wf(21,:)); % channel realizations at 10dB SNR
range_44_wf=0:0.1:max(c44_all_wf);
count44_wf=histc(c44_all_wf,range_44_wf);
count44_norm_wf=cumsum(count44_wf)/max(cumsum(count44_wf));
comp_CDF_44_wf=1-count44_norm_wf;
%%
%outage prob
j1= 1;
for i1=find(SNR_dB==2):find(SNR_dB==20)
c44_all=abs(c44_i(i1,:));
range44=0:0.1:max(c44_all);
count44=histc(c44_all,range44);
count44_norm=cumsum(count44)/max(cumsum(count44));
if(isempty(find(abs(range44-c_outage)<epsilon)))
outage44(j1)=1;
else
outage44(j1)=count44_norm(find(abs(range44-c_outage)<epsilon));
end
j1=j1+1;
end
%%MIMO WF
j1= 1;
for i1=find(SNR_dB==2):find(SNR_dB==20)
c44_all_wf=abs(c44_i_wf(i1,:));
range44_wf=0:0.1:max(c44_all_wf);
count44_wf=histc(c44_all_wf,range44_wf);
count44_norm_wf=cumsum(count44_wf)/max(cumsum(count44_wf));
if(isempty(find(abs(range44_wf-c_outage)<epsilon)))
outage44_wf(j1)=1;
else
outage44_wf(j1)=count44_norm_wf(find(abs(range44_wfc_outage)<epsilon));
end
j1=j1+1;
end
%% >>>>>>>>>>>>>>>>>>>>> ... SIMO (1x4) ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% initialization and param setting
Nr=4;
Nt=1;
c14_i=zeros(length(SNR),ch_realizations);
c14=zeros(length(SNR),1);
% matrix initializations to avoid matrix growing inside loop
% Mean channel capacity calculations
for i1=1:length(SNR)

SNR_i= SNR(i1); % for one specific value of SNR


h14=1/sqrt(2).*complex(randn(Nr*Nt,ch_realizations),randn(Nr*Nt,ch_realizatio
ns));
% complex normal r.v. having var=1/2 per dim.
h14_mag_sq=abs(h14).^2;
h14_mag_sq_sum=sum(h14_mag_sq);
c14_i(i1,1:ch_realizations)=log2(1+SNR_i.*h14_mag_sq_sum); %
instantaneous cap.
c14(i1)=mean(c14_i(i1,:)); % mean capacity
end
%complementary CDF at SNR=10dB
c14_all=c14_i(21,:); % channel realizations at 10dB SNR
range_14=0:0.1:max(c14_all);
count14=histc(c14_all,range_14);
count14_norm=cumsum(count14)/max(cumsum(count14));
comp_CDF_14=1-count14_norm;
%outage probability
j1= 1;
for i1=find(SNR_dB==2):find(SNR_dB==20)
c14_all=abs(c14_i(i1,:));
range14=0:0.1:max(c14_all);
count14=histc(c14_all,range14);
count14_norm=cumsum(count14)/max(cumsum(count14));
if(isempty(find(abs(range14-c_outage)<epsilon)))
outage14(j1)=1;
else
outage14(j1)=count14_norm(find(abs(range14-c_outage)<epsilon));
end
j1=j1+1;
end
%% >>>>>>>>>>>>>>>>>>>>> ... MISO (4x1) ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% initialization and param setting
Nr=1;
Nt=4;
c41_i=zeros(length(SNR),ch_realizations);
c41=zeros(length(SNR),1);
% matrix initializations to avoid matrix growing inside loop
% Mean channel capacity calculations
for i1=1:length(SNR)
SNR_i= SNR(i1); % for one specific value of SNR
h41=1/sqrt(2).*complex(randn(Nr*Nt,ch_realizations),randn(Nr*Nt,ch_realizatio
ns));
% complex normal r.v. having var=1/2 per dim.
h41_mag_sq=abs(h41).^2;
h41_mag_sq_sum=sum(h41_mag_sq);
c41_i(i1,1:ch_realizations)=log2(1+(SNR_i./Nt).*h41_mag_sq_sum); %
instantaneous cap.
c41(i1)=mean(c41_i(i1,:)); % mean capacity
end

%complementary CDF at SNR=10dB


c41_all=c41_i(21,:); % channel realizations at 10dB SNR
range_41=0:0.1:max(c41_all);
count41=histc(c41_all,range_41);
count41_norm=cumsum(count41)/max(cumsum(count41));
comp_CDF_41=1-count41_norm;
%outage probability
j1= 1;
for i1=find(SNR_dB==2):find(SNR_dB==20)
c41_all=abs(c41_i(i1,:));
range41=0:0.1:max(c41_all);
count41=histc(c41_all,range41);
count41_norm=cumsum(count41)/max(cumsum(count41));
if(isempty(find(abs(range41-c_outage)<epsilon)))
outage41(j1)=1;
else
outage41(j1)=count41_norm(find(abs(range41-c_outage)<epsilon));
end
j1=j1+1;
end
%% >>>>>>>>>>>>>>>>>>>> ... Plotting ... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% Mean channel capacity
figure('Name','Mean Capacity comparisons (vs SNR) for Flat Fading MIMO
channels');
plot(SNR_dB,abs(c44_wf),'bx-',SNR_dB,abs(c44),'ro',SNR_dB,c41,'c+',SNR_dB,c14,'gs-',SNR_dB,c11,'b:');
legend('4x4 MIMO WF','4x4 MIMO','4x1 MISO','1x4 SIMO','1X1
SISO','Location','NorthWest');
title('Mean Capacity vs SNR');
xlabel('SNR (dB)
--->');
ylabel('Mean Capacity bps/Hz
--->');
axis([-10 30 0 40]);
%complementary CDF at SNR=10dB
figure('Name','Complementary CDF at SNR = 10dB');
plot(range_44_wf,comp_CDF_44_wf,'bx',range_44,comp_CDF_44,'ro',range_41,comp_CDF_41,'c+',range_14,comp_CDF_14,'gs-',range_11,comp_CDF_11,'b:');
legend('4x4 MIMO WF','4x4 MIMO','4x1 MISO','1x4 SIMO','1X1
SISO','Location','NorthEast');
title('Complementary CDF comparisons (vs capacity) at SNR=10dB');
xlabel('Mean Capacity bps/Hz
--->');
ylabel('1 - Outage Probability
--->');
axis([0 15 0.9 1]);
%outage probability vs SNR for 4 bps/Hz
figure('Name','Outage probability comparisons (vs SNR) for Flat Fading
Channels');
%plot(range_44,comp_CDF_44,'bx',range_44,comp_CDF_44,'ro',range_41,comp_CDF_41,'c+',range_14,comp_CDF_14,'gs-',range_11,comp_CDF_11,'b:');
semilogy(SNR_dB(find(SNR_dB==2):find(SNR_dB==20)),outage44_wf,'bx',SNR_dB(find(SNR_dB==2):find(SNR_dB==20)),outage44,'ro',SNR_dB(find(SNR_dB==
2):find(SNR_dB==20)),outage41,'c+-

',SNR_dB(find(SNR_dB==2):find(SNR_dB==20)),outage14,'gs',SNR_dB(find(SNR_dB==2):find(SNR_dB==20)),outage11,'b:');
legend('4x4 MIMO WF','4x4 MIMO','4x1 MISO','1x4 SIMO','1X1
SISO','Location','SouthEast');
title('Outage probability vs SNR for 4 bps/Hz');
xlabel('SNR in dB
--->');
ylabel('Outage Probability
--->');
axis([2 20 1e-6 1]);
% MIMO water-filling capacity gain
figure('Name','capacity gain of water-filling');
plot(SNR_dB,abs(c44_wf)'-abs(c44));
grid on;
title('WF gain in capacity');
xlabel('SNR in dB
--->');
ylabel('WF gain in bps/Hz
--->');

You might also like