Professional Documents
Culture Documents
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.2 Problem Definition and Methodology . . . . . . . . . . . . . . . . 3
0.2.1 Uniform random number generation . . . . . . . . . . . . 3
0.2.2 Gaussian random number generation . . . . . . . . . . . . 3
0.2.3 Modulation through an AWGN channel . . . . . . . . . . 3
0.2.4 BPSK with a phase offset . . . . . . . . . . . . . . . . . . 5
0.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.3.1 Uniform random number generation . . . . . . . . . . . . 6
0.3.2 Gaussian random number generation . . . . . . . . . . . . 7
0.3.3 Modulation through an AWGN channel . . . . . . . . . . 8
0.3.4 BPSK with a phase offset . . . . . . . . . . . . . . . . . . 9
0.4 Discussion and Conclusion . . . . . . . . . . . . . . . . . . . . . . 9
1
0.1 Introduction
The role of digital communications
As the amount of information at our fingertips increases and the demand for
increasingly rapid transfer rates grows greater - The common denominator of all
interaction in the digital sphere is encompassed by the concept of digital com-
munication. Digital communication is defined as the physical transfer of data
over a communication channel. We are surrounded by digital communications
every minute of every day, from the mouse you use on your computer to the
mobile telephone in your pocket right now.
Phase-shift Keying
Phase-shift keying is a scheme of digital modulation that deals with represen-
tation of different data signals through the use of a phase-shift on the reference
signal of varying degrees. Two forms of PSK are explored in this practical -
namely Binary phase shift keying (BPSK) and Quadrature Phase shift keying
(QPSK). [1]
2
0.2 Problem Definition and Methodology
0.2.1 Uniform random number generation
The probability distribution function of the uniform distribution can be de-
scribed by [2]:
1
f (x) = b−a for a ≤ x ≤ b
f (x) = 0 elsewhere
(b − a)2 1
σ2 = = = 0.083
12 12
To generate random numbers conforming to this uniform distribution, we will
use the Wichmann-Hill Algorithm.
rk = sk + nk
Where r is the received symbol, s is the sent symbol and n is a noise term. It
can be deduced from the inequality present by the non-zero n term that the
received signal will differ slightly by the sent signal s. The AWGN network will
be simulated as described in the flow-chart.
3
Figure 2: Flow chart depicting the methodology behind simulating the AWGN
channel
4
0.2.4 BPSK with a phase offset
This report will also explore the effects of a constant phase-shift applied to the
BPSK coding and whether or not this has an effect even in an AWGN channel
with additive real and imaginary noise. If the bit error rate truly is a function
of orthogonality, there should be no apparent difference in BER plots.
5
0.3 Results
0.3.1 Uniform random number generation
The uniform number generation results proved consistent with the theoretical
approximation. Slight subtleties visible are due to a finite number of samples
limited to 1 million, with an increase in samples the inconsistencies tend to be-
come less prevalent. Despite the differences, the mean still stays exceptionally
close to the theoretical mean of 0.5 and theoretical variance of 0.0833. Calcu-
lated values for the simulation can be seen in figure 3.
6
0.3.2 Gaussian random number generation
Gaussian number generation proved to work well, with a mean difference from
the theoretical value that was extremely small.
Figure 5: Results of the Marsaglia-Bray algorithm for 1 million samples and the
theoretical normal distribution
7
0.3.3 Modulation through an AWGN channel
8
0.3.4 BPSK with a phase offset
Figure 8: A plot showing offset BPSK vs regular BPSK bit error rates.
Results for the BPSK/QPSK graphs showed that both phase-shift keying meth-
ods shared the exact same BER plots. This is further illustrated in figure 9.
9
Figure 9: Plot showing BER for BPSK vs QPSK
This is not initially intuitive, transmitting multiple bits at a time seems like it
should have a trade-off in fidelity. However, QPSK symbol mapping is simply
a duo of BPSK signals that are perfectly orthogonal to each other - one BPSK
system on the real axis and another on the imaginary axis. Due to their orthog-
onality, they hence do not interfere. Analysis (in figure 8) shows that the BER
plots for offset BPSK and regular BPSK do in-fact match each other perfectly.
This is due to the fact that the bit error rate is a function of orthogonality, since
both offset and regular BPSK share the same 180 deg phase shift between their
associated symbols.
It can be concluded that, BPSK and QPSK are digital modulation schemes
with a good fidelity when transmitting through an additive white Gaussian
noise channel provided that the SNR is of an acceptable degree. We can also
conclude that signal fidelity is a function of orthogonality between symbols. It
can be seen (by figure 9) that QPSK and BPSK both share the same BER
plot. If the symbol rate (bandwidth) is the same for BPSK and QPSK, QPSK
will perform considerably worse with the same signal power. This performance
consideration is alleviated by QPSK’s higher symbol rate so it appears to have
the same BER as BPSK. Therefore, QPSK achieves the same bit error rate at
the cost of added signal power required to transmit.
10
Bibliography
11
Appendix A: MATLAB code
Question 1.m
close all
clear
clc
% sample size:
sample size = 1000000; % no of numbers to generate.
samples = zeros(1,sample size);
a = clock;
s1 = sum(a(1:6));
s2 = floor(prod(a(4:6)));
s3 = floor(prod(a(1:2)));
stairs(x,pdf1,'r','LineWidth',2);
ylim([0 1.1]);
hold off;
12
Question 2.m
close all
clear
clc
% sample size:
sample size = 10000000; % no of numbers to generate.
samples = zeros(1,sample size);
x = [-3:.1:3];
norm = normpdf(x,0,1);
plot(x,norm, 'r');
13
Question 3 BPSK.m
% question 3 new:
close all;
clear all;
clc;
% run loop for: minimum of n=100 bits have been run and min of 50 error
% bits detected.
% seeds:
a = clock;
s1 = sum(a(1:6));
s2 = floor(prod(a(4:6)));
s3 = floor(prod(a(1:2)));
for i=1:length(SNRdB)
% for every dB of SNR we want to iterate through, we need to generate
% and test bits through the AWGN channel until we get min of 50 errors
% or min of 100 bits.
nErrorsAvg = 0;
for n=1:noRunsEach
if ( ((s+1)/2) ~= (r > 0) )
nErrors = nErrors + 1;
end
nBits = nBits + 1;
end
nErrorsAvg = nErrorsAvg + nErrors;
end
14
% at this point, we have a pretty good estimation of the number of
% errors so:
BERvalues(i) = (nErrorsAvg/ noRunsEach) / nBits;
disp('Finished an SNR level');
end
15
Question 3 QPSK.m
% question 3:
%%%%%%%%
% QPSK %
%%%%%%%%
close all;
clear all;
clc;
% run loop for: minimum of n=100 bits have been run and min of 50 error
% bits detected.
% seeds:
a = clock;
s1 = sum(a(1:6));
s2 = floor(prod(a(4:6)));
s3 = floor(prod(a(1:2)));
tTime = 0;
for i=1:length(SNRdB)
% for every dB of SNR we want to iterate through, we need to generate
% and test bits through the AWGN channel until we get min of 50 errors
% or min of 100 bits.
tic;
nErrorsAvg = 0;
for n=1:noRunsEach
16
% demodulate:
dR = (sign(real(r))+1)/2; % sign function divides component by mag.
dI = (sign(imag(r))+1)/2; % and convert to binary rep.
if ( ((sR+1)/2) ~= dR )
nErrors = nErrors + 1;
end
if ( ((sI+1)/2) ~= dI )
nErrors = nErrors + 1;
end
nBits = nBits + 2;
end
nErrorsAvg = nErrorsAvg + nErrors;
end
17
WichmannHill.m
function [r , x, y, z] = WichmannHill(x,y,z)
end
MarsagliaBray.m
% marsaglia-bray
function R1 = MarsagliaBray()
s = 1;
while ( s >= 1 )
v1 = 2 * rand - 1;
v2 = 2 * rand - 1;
s = v1*v1 + v2*v2;
end
L = sqrt(-2 * log(s) / s);
R1 = v1 * L;
end
getSigma.m
end
18
ExtraBPSK.m
close all;
clear all;
clc;
% run loop for: minimum of n=100 bits have been run and min of 50 error
% bits detected.
% seeds:
a = clock;
s1 = sum(a(1:6));
s2 = floor(prod(a(4:6)));
s3 = floor(prod(a(1:2)));
for i=1:length(SNRdB)
% for every dB of SNR we want to iterate through, we need to generate
% and test bits through the AWGN channel until we get min of 50 errors
% or min of 100 bits.
nErrorsAvg = 0;
for n=1:noRunsEach
r = s + (getSigma(SNRdB(i), 1) * MarsagliaBray());
r = r + (getSigma(SNRdB(i), 1) * MarsagliaBray())*1i; % complex noise.
% now we know we received r.
% does the logical binary interpretation of r match that of s ?
% now for the comparative logic:
19
% if the delta value of S1 is smaller than delta of S2 we know
% that it is S1.
if ( abs( r - constS1 )ˆ2 < abs( r - constS2)ˆ2)
dR = (1./sqrt(2)) + (1i./sqrt(2)); % S1
else
dR = (-1./sqrt(2)) + (-1i./sqrt(2)); % S2
end
if (dR ~= s)
nErrors = nErrors + 1;
end
nBits = nBits + 1;
end
nErrorsAvg = nErrorsAvg + nErrors;
end
end
20