(10 votes, average: 3.30 out of 5)

# Deriving PDF of Rayleigh random variable

by on July 17, 2008

In the post on Rayleigh channel model, we stated that a circularly symmetric random variable is of the form $Z = X + jY$, where real and imaginary parts are zero mean independent and identically distributed (iid) Gaussian random variables. The magnitude $|Z|$ which has the probability density,

$p(z) = \frac{z}{\sigma^2}e^{\frac{-z^2}{2 \sigma^2}},\ \ \ z\ge 0$

is called a Rayleigh random variable. Further, the phase $\theta$ is uniformly distributed from $[0,\ 2\pi]$. In this post we will try to derive the expression for probability density function (PDF) for $|Z|$ and $\theta$.

The text provided in Section 5.4.5 of [ELECTRONIC-COMMUNICATION:PRADIP] is used as reference.

## Joint probability

The probability density function of $x$ is

$p(x) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{\frac{-x^2}{2\sigma^2}}$.

Similarly probability density function of $y$ is

$p(y) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{\frac{-y^2}{2\sigma^2}}$.

As $X$ and $Y$ are independent random variables, the joint probability is the product of the individual probability, i.e,

$p(x,y) = \frac{1}{{2\pi\sigma^2}}e^{\frac{-(x^2+y^2)}{2\sigma^2}}$.

The joint probability that the random variable $X$ lies between $x$ and $x+dx$ and the random variable $Y$lies between $y$ and $y+dy$is,

$P(x\le X+dx,y\le Y+dy)=\frac{1}{{2\pi\sigma^2}}e^{\frac{-(x^2+y^2)}{2\sigma^2}}dxdy$.

## Conversion to polar co-ordinate

Given that $(x,y)$ is in the Cartesian co-ordinate form, we can convert that into the polar co-ordinate $(z,\theta)$ where,
$Z=\sqrt{X^2+Y^2}$ and
$\Theta = \tan^{-1}\left(\frac{Y}{X}\right)$.

Figure: Cartesian co-ordinate to polar co-ordinate

The area $dxdy$ is Cartesian co-ordinate form is equal to the area $zdzd\theta$ in the polar co-ordinate form.

$P(x\le X+dx,y\le Y+dy)=P(z\le Z+dz,\theta\le \Theta+d\theta)$.

Simplifying,
$\begin{eqnarray}P(z\le Z+dz,\theta\le \Theta+d\theta)&=&\frac{1}{{2\pi\sigma^2}}e^{\frac{-(x^2+y^2)}{2\sigma^2}}zdzd\theta\\&=&{\frac{z}{{\sigma^2}}e^{\frac{-z^2}{2\sigma^2}}}dz{\frac{1}{2\pi}}d\theta\end{eqnarray}$.

Summarizing the joint probability density function,

$p(z,\theta) = \frac{z}{{2\pi\sigma^2}}e^{\frac{-z^2}{2\sigma^2}}$.

Since $z$ and $\theta$ are independent, the individual probability density functions are,
$\huge p(z) = \frac{z}{{\sigma^2}}e^{\frac{-z^2}{2\sigma^2}},\ z\ge 0$,

$\huge p(\theta) = \frac{1}{2\pi},\ -\pi \le \theta \le \pi$.

## Simulation Model

Simple Matlab/Octave simulation model is provided for plotting the probability density of $z$ and $\theta$. The script performs the following:

(a) Generate two independent zero mean, unit variance Gaussian random variables

(b) Using the hist() function compute the simulated probability density for both $z$ and
$\theta$

(c) Using the knowledge of the equation (which we just derived), compute the theoretical probability
density function (PDF)

(d) Plot the simulated and theoretical probability density functions (PDF) and show that they are in good agreement.

Figure: Simulated/theoretical PDF of Rayleigh random variable

Figure: Simulated/theoretical PDF of uniformly distributed theta random variable

## Reference

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.

Sami Aldalahmeh January 16, 2012 at 7:03 pm

Hi,
I looked at the code and noticed in line 34, when you plot the histogram of the simulated Rayleigh pdf, you divided by 0.01 that is the step of the zBin variable. Is there any intuitive explanation for this? Furthermore, if you sum, approximately integrate, the value for both theoretical pdfs of the Rayleigh distribution you don’t get one. However, if you don’t divide with 0.01 and multiply the theoretical pdf with 0.01 instead, you get one when sum. Maybe this is due MATLAB being not able to purely represent continuous functions? What do you think?

Krishna Sankar January 26, 2012 at 6:39 am

@Sami: Good questions. Am trying to recall why I did it that way… quite likely as you said, it might be due to the continuous vs discrete sample aspect. Will revert back if i find a better explanation…
Thanks again.

mohsen December 21, 2011 at 12:34 pm

Dear Krishna
would you please send me the reference which u use to get this:
h = 1/sqrt(2)*(randn(1,1000) + j*randn(1,1000)) % rayleigh random variable

Krishna Sankar January 3, 2012 at 4:44 am

@mohsen: This is generate complex gaussian noise with zero mean and unit variance.

PeterRay February 17, 2010 at 9:01 pm

Hello Krishna,
I am new to matlab. I need some help. Suppose we have ‘Nr x Nt’ MIMO channel matrix.And we assume iid rayleigh fading. So the magnitude of every entry will be rayleigh distributed. Now at the receiver side we have ‘Nr’ receive antennas and at every antenna we will have a set of values for every transmitted symbol. I wish to plot the pdf of the output values. (like the output SNR). How do I find the pdf then ? What kind of pdf will it be ? Further if I have to toss independent and non identical channels how to I do that ? we usually write “(1/sqrt(2))*(randn(Nr,Nt)+j*randn(Nr,Nt))” for a typical unit variance zero mean channel.Please correct me if my understanding is wrong. Any help would be appreciated.

Krishna Sankar April 4, 2010 at 3:49 am

@PeterRay: My replies
a) You can use the histogram (hist function in Matlab) to obtain the PDF.
b) One needs to the write the equations to figure out the nature of the PDF
c) Did you mean, you want to add correlation to the channel coefficients?

mesange December 9, 2009 at 1:33 pm

Dear Krishna I hope you are doing good !!!
I have question relating to gaussian random variables, i need to plot the pdf of the following:

=summation(from i=0 to i = P) |H^i|²

where H are circularly symmetric complex Gaussian random variables …
I donno how to do it in matlab ,,, kindly help
mesange.