Sie sind auf Seite 1von 10

Bit Error Rate (BER) for BPSK modulation

by Krishna Sankar on August 5, 2007


(http://www.dsplog.com/2007/08/05/bit-error-probability-for-bpsk-modulation/#Simulation
%20Model)
In this post, we will derive the theoretical equation for bit error rate (BER) with Binary Phase
Shift Keying (BPSK) modulation scheme in Additive White Gaussian Noise (AWGN) channel.
The BER results obtained using Matlab/Octave simulation scripts show good agreement with the
derived theoretical results.
With Binary Phase Shift Keying (BPSK), the binary digits 1 and 0 maybe represented by the
analog levels
and
respectively. The system model is as shown in the Figure below.

Figure: Simplified block diagram with BPSK transmitter-receiver

Channel Model
The transmitted waveform gets corrupted by noise
Gaussian Noise (AWGN).

, typically referred to as Additive White

Additive : As the noise gets added (and not multiplied) to the received signal
White : The spectrum of the noise if flat for all frequencies.
Gaussian : The values of the noise
with

follows the Gaussian probability distribution function,


and

Computing the probability of error


Using the derivation provided in Section 5.2.1 of [COMM-PROAKIS] as reference:

The received signal,


when bit 1 is transmitted and
when bit 0 is transmitted.
The conditional probability distribution function (PDF) of

for the two cases are:

Figure: Conditional probability density function with BPSK modulation


Assuming that
and
decision boundary.

are equally probable i.e.

, the threshold 0 forms the optimal

if the received signal is


transmitted.

is greater than 0, then the receiver assumes

was

if the received signal is


transmitted.

is less than or equal to 0, then the receiver assumes

was

i.e.
and
2

Probability of error given

was transmitted

With this threshold, the probability of error given

is transmitted is (the area in blue region):

,
where,

is the complementary error function.

Probability of error given

was transmitted

Similarly the probability of error given

is transmitted is (the area in green region):

Total probability of bit error


.
Given that we assumed that
error probability is,

and

are equally probable i.e.

, the bit

Simulation model
Matlab/Octave source code for computing the bit error rate with BPSK modulation from theory
and simulation. The code performs the following:
(a) Generation of random BPSK modulated symbols +1s and -1s
(b) Passing them through Additive White Gaussian Noise channel
(c) Demodulation of the received symbol based on the location in the constellation
(d) Counting the number of errors
(e) Repeating the same for multiple Eb/No value.

Click here to download Matlab/Octave script for simulating BER for BPSK modulation in
AWGN chnanel.

Figure: Bit error rate (BER) curve for BPSK modulation theory, simulation

Reference
[DIGITAL COMMUNICATION: PROAKIS] Digital Communications by John Proakis

MATLAB CODE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Creative Commons
% Attribution-Noncommercial 2.5 India
% You are free:
% to Share to copy, distribute and transmit the work
% to Remix to adapt the work
% Under the following conditions:
% Attribution. You must attribute the work in the manner
% specified by the author or licensor (but not in any way
% that suggests that they endorse you or your use of the work).
% Noncommercial. You may not use this work for commercial purposes.
% For any reuse or distribution, you must make clear to others the
% license terms of this work. The best way to do this is with a
% link to this web page.
% Any of the above conditions can be waived if you get permission
% from the copyright holder.
% Nothing in this license impairs or restricts the author's moral rights.
% http://creativecommons.org/licenses/by-nc/2.5/in/
%
%
%
%
%
%
%
%
%

Script for simulating binary phase shift keyed transmission and


reception and compare the simulated and theoretical bit error
probability
Checked for proper operation with Octave Version 3.0.0
Author
: Krishna
Email
: krishna@dsplog.com
Version
: 1.0
Date
: 5 August 2007
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear
N = 10^6 % number of bits or symbols
rand('state',100); % initializing the rand() function
randn('state',200); % initializing the randn() function
% Transmitter
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB
variance
Eb_N0_dB = [-3:10]; % multiple Eb/N0 values
for ii = 1:length(Eb_N0_dB)
% Noise addition
y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise
% receiver - hard decision decoding
ipHat = real(y)>0;
% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);
end
simBer = nErr/N; % simulated ber
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber

% plot
close all
figure
semilogy(Eb_N0_dB,theoryBer,'b.-');
hold on
semilogy(Eb_N0_dB,simBer,'mx-');
axis([-3 10 10^-5 0.5])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK modulation');

Questions & Answers:


Q: How do we demodulate , decode and compare it with the input signal?
A: For BPSK it is simple. We observe the real part of the received symbol. If the real part is
greater than 0 decode as +1, if the real part is less than 0 decode as -1. Once we have the decoded
symbols available, the number of differing symbols can be obtained by nErr = size(find([ipipHat]),2); Ofcourse, using find() is only one among the many different ways to compute this.
Q: Why are we using this term 10^(-Eb_N0_dB(ii)/20) in the code to get the final signal y. Why
cant we write y=s+n; ? I am unable to understand the FOR loop operation in this code.
A: The term 10^(-Eb_N0_dB(ii)/20) is for scaling the noise power as per the defined bit to noise
ratio. The for loop is for computing the bit error rate for each Eb/N0 value.
Q: Why you are multiplying n with The term 10^(-Eb_N0_dB(ii)/20).
A: This is to scale the noise term n, so that we can obtain BER for different values of Eb/No. In
the simulations, we define Eb/No in dB. To convert dB to define a scaling term for noise voltage,
we use 10^(Eb_N0_dB/20).
Q: Why didnt you use the awgn matlab function to introduce the noise? Why have we taken this
formula?
A: Typically, to keep the code simple, I tried to avoid in-built functions. The randn() function +
scaling the does the job. Thats all.
Q: About the formula u uzed for awgn i didnt get how it produces awgn?
A: The randn() function generates a random variable having Gaussian distribution and the
spectrum of this random variable is same across frequencies. Hence the name White Gaussian
Noise (WGN). This is then Added to the signal, hence the name Additive White Gaussian Noise
(AWGN). [randn(1,N) + j*randn(1,N)] generates complex Gaussian noise with mean 0 and

variance 2. To make the variance to 1, the scaling factor of 1/sqrt(2) is used. The j term is for
complex noise.
Q: I do not understand why a complex gaussian noise is required. The source here belongs to a
BPSK modulation so I think, in practice we have a real noise, because we do just activate the in
phase component and not the quadrature phase component.
A: You are right, the imaginary component is ignored. In fact if you see the simulation model,
for demodulating the symbol, we use only the real part of the received signal. However, our
definition of noise is with a variance of N0/2 on the real arm and N0/2 on the imaginary arm.
Q: Might want to consider using a separate integration variable for the definition of the erfc
function, since the variable x was used for both the erfc argument and integration variable.
Perhaps just use z or y for the erfc integration variable, i.e., erfc(x) = 2/sqrt(pi) *
Integral_x_inf { exp(-z^2/2)*dz } . This will then make it clear that the erfc argument x is used
to modify the integration limits, as opposed to the actual function being integrated.
A: Yeah, thanks for the suggestion. I agree that your proposal will make the text even more
readable. Anyhow, may I recommend to keep status quo given that the current text is not making
it very difficult for the reader.
Q: for QPSK modulation, the variance is
sigma = 1/sqrt(10.0^(snr/10.0));
sigma=sigma/2;
Do you have any idea why it has to devide by 2?
A: There is noise on the real and imaginary dimension. So, to make the total variance of the
complex noise to unity, there is scaling by 1/2.
Q: receiver hard decision decoding
ipHat = real(y)>0;
here what do you mean by hard decision decoding? plz reply in brief.
A: It just means that any value of y (real component) greater than 0 is assigned to 1 and if less
than 0 is assigned as 0. This is called hard decision decoding. Soft decisions where we do not
decide on what was transmitted based on the received constellation are used typically when
there is a decoder block (like Viterbi) following the constellation demapping.
Q: Could you shade light on the derivation of Sigma^2 = No/2 from correlation and spectral
density of noise stand point?
A: The term N0/2 corresponds to the spectral density of white noise. In typical systems, we
experience white noise filtered by an ideal LPF. The variance of this filtered noise contributes to
the noise term in the system.
7

You may look at chapter 9 in Communication Systems An introduction to Signals and noise in
Electrical Communication by A. Bruce Carlson, Paul Crilly, Janet Rutledge for further details.
Q: In your code you have scaled the noise with the term 10^(-Eb_N0_dB(ii)/20)
my question is why we do this? I mean why we need to scale the noise power as per the defined
bit to noise ratio?
A: In this analysis, our objective is to analyze the impact of noise on the reliable decoding of
BPSK modulation. To analyze the impact, we need to find out the performance (bit error rate) for
different values of noise. Hence we scale the noise by noise power.
We need to untimately multiply with standard deviation of noise so we get 20 there
SNRdB = 20 log (Asignal / Anoise)
-SNRdB = 20 log(Anoise / Asignal)
-SNRdB/20 = log(Anoise / Asignal)
10^(-SNRdB/20) = Anoise/Asignal < noise amplitude scaling factor.
Q: The term 10^(-Eb_N0_dB(ii)/20) is for scaling the noise power as per the defined bit to noise
ratio, why divided it by 20 >>??to convert it to voltage
A: Yes, divided it by 20 is to convert to voltage.
Q: Could you go in to a little more detail why you use complex noise vs. real. Although it
doesnt make a difference for BPSK, Im assuming it actually will with other modulation
methods. I didnt see this in any of my textbooks.
A: Yes, for BPSK the noise component on the imaginary arm is ignored. To make the noise
model same as with other modulation schemes, I kept it as complex.
Q: In your code for the BPSK, you divide by 20. Shouldnt that be 10? Given an SNR in dB, we
get S/N0 = 10*log(SNR-dB / 10).
This gives N0 for a given signal power S.
The variance^2 = N0/2 and if we assume 0 mean, this gives us our AWGN, which is a random
variable describing the noise amplitude. In my simulation, if I use 10 instead of 20, my results
were way off, but 10 gives a perfect match with theory.
A: The division by 20 is to convert the dB to scale the voltage signal. In my simulation model,
the noise term n is a Gaussian random variable with mean 0 and variance 1. Therefore, I am
scaling the noise voltage by 10^(-Eb_N0_dB(ii)/20)*n. Thats why I used 20.
In general, it depends on how one creates the model. Different people have different coding style.
However, its the end result which matters.
Q: I want to replace Eb/N0 as SNR how can I do it.Could you pls help me urgently.
A: For BPSK. Eb/N0 is same as SNR
Q: please can you tell me what does this instruction do exactly
8

ipHat = real(y)>0;
is it equivalent to
if (real(y)>0)
ipHat = 1
else
ipHat = 0
end
A. Your explanation is correct. As you may be aware, Matlab provides lots of quick one liner
ways to do things
Q: i have some question
1. y = s + 10^(-Eb_N0_dB(ii)/20)*n;
2. theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10)))
i don`t know why Eb_N0_dB(ii) has minus value
and
At first term,^(-Eb_N0_dB(ii) is divided by 20 but, at second term Eb_N0_dB is divided by 10.
Why Eb_N0_dB is divided by diferrent value??
A: 1/ Before this scaling, the signal term s and the noise term n has the same variance of 1. The
term -Eb_N0_dB reduces the noise variance
2/ The scaling is happening on the noise voltage signal, hence the factor of 1/20. In the theoretical
equation, note that there is a square root term outside the 1/10 factor. This is equivalent to having
1/20 factor.
Q: Could you help me to know what is the role of the following
rand(state,100); % initializing the rand() function
randn(state,200); % initializing the randn() function
A: The random numbers generated by the program can be initialized to enable us to run multiple
simulations with the exact same random numbers . Setting the state of the rand() or randn()
enables one to do so.
Use >>help rand or >> help randn to get more information.
Q: I have actually read the answers given to you by the concerns generated by the formula below
10^(-Eb_N0_dB(ii)/20)*n for further clarification, i have actually divided by 18,16,14,123
to get different plots that actually decreases down the graph . Want to know if is how one can plot
for BER with variable noise in the channel. I will appreciate if you reply me soon.
A: Do not change the division factor. Rather change the value of Eb_N0_dB. The division by 20
is required to convert dB into voltage.
Q: Pls in essence how and where do we set the different values for EbNo/ or S/N or SNR to
achieve different BER plots using your simulation example.
A: Change Eb_N0_dB.
9

Q: Why you are using 10^(-Eb_No_db(ii)/20) the minus sign in this formula because for voltage
scaling it should be 10^(Eb_No_db(ii)/20).
A: The negative sign came as I am scaling the noise voltage. I am keeping the signal swing the
same and reducing the swing of noise voltage to simulate various Eb/N0 values.
Q: is erfc equal Q function?
A: No, erfc is not equal to Q function, but both are related.
http://en.wikipedia.org/wiki/Q-function
Q: i just wondering why we need to initialize the rand and randn function?
A: If we initialize, we can ensure that the same random numbers are generated in any run
Q: I have question about the comment of this line in your codes
s = 2*m-1; % BPSK modulation 0 -> -1; 1 -> 0
I think maybe you want to change original 0 to -1, but 1 should be no change, is it?
A: Thanks for noticing the typo in the comment. I corrected
Q: please can you tell me how that is discussed if you write this statement 0db variance
in this line of code
n = 1/sqrt(2)*[randn(1,N)] %+ j*randn(1,N)]; % white gaussian noise, 0dB variance
really , please can you illustrate me which part exactly in the code do this thing as the part the i
see in the code is
n = 1/sqrt(2)*[randn(1,N)]; %+ j*randn(1,N)]; % white gaussian noise, 0dB variance
and you write as comment that the noise is 0 db variance
A: The 0dB variance is for complex noise (on both real and imaginary part). For BPSK we use
only real part and the variance is 1/2.

10

Das könnte Ihnen auch gefallen