Beruflich Dokumente
Kultur Dokumente
of Random Variables
by Laurence G. Hassebrook
1-27-2013
Using only the uniformly distributed sample values from the pseudo random number generator
rand() of MATLAB, generate Gaussian and Rayleigh distributions using techniques from
functions of random variables Generate noise sequences of length N. Bin them in Nbin=100
bins and normalize to represent pdf estimates.
1. Uniform Distributions
Generate two uniform distributions, [0,1] and the other with 0 mean and unit standard deviation.
The initial Matlab code is
which clears all the values and sets the vector length and histogram resolution. The pseudo-
random vector is generated as
1
xu ,1 ~ U 0,1 is 0.5 and the = 1/sqrt(12). To generate a uniform r.v. with 0
The mean value of ~
mean and unit variance we subtract the mean value and then divide by the STD such that:
~ x 0.5
xu , Norm u ,1 (1)
urv1=(urv-0.5)*sqrt(12);
Generate two uniform distributions, [0,1] that are independent and identically distributed.
The Matlab code is
ur1=rand(1,N);
ur2=rand(1,N);
g~1 n 2 ln ~
xu ,1 n cos2 ~
xu , 2 n (2)
g~2 n 2 ln ~
xu ,1 n sin 2 ~
xu , 2 n (3)
2
3. Rayleigh Distributions from Gaussian Distributions
Generate Rayleigh distribution from the two Gaussian sequences generated in Section 2. The
function used to generate a Rayleigh r.v is
r n g~12 n g~22 n
~ (4)
Note that the Rayleigh samples are always positive. The mean value of a Rayleigh r.v. is related
to the standard deviation, = 1, of the Gaussian r.v.s used to generate it such that
r (5)
2
4
r (6)
2
r 2
f ~r r
r 2 2
e , for r > 0 (7)
2
3
4. Normalizing the Distributions to have zero Mean and unit Variance
If often happens that we will be presented with signal data in the way of a picture, photograph or
image as seen in Figs. 1.1, 2.1 or 3.1. Usually these noise signals are added to an underlying
signal of some sort. It is helpful to be able to visually estimate the relative noise level compared
with the signal level as well as the type of noise that it is. In this section, we normalize the
uniform, Gaussian and Rayleigh noise sequences to have zero mean and unit variance. We then
view them side by side and note the similarities and differences between the noise signals.
Figure 4.1: The three histogrammed distributions superimposed to show range and amplitude of their estimated
distributions.
The normalization, of the signals in Sections 1 through 3, requires that (1) the known ensemble
mean value is first subtracted from the signal values (2) followed by division by the standard
deviation. The resulting signals are plotted in Fig. 4.1.
4
Figure 4.2: Normalized distributions. (left) Uniform, (center) Gaussian and (right) Rayleigh.
If you squint your eyes and look at Fig. 4.2, you should see a band of darkness that ranges from
about -1.5 to 1.5. Knowing this, you would know an estimate of the STD as 1.0 or 2/3s of what
you visualize as the dense data band. Another thing you note is the sharpness of the top and
bottom edge. A uniform edge is sharp on top and bottom, Gaussian is fuzzy top and bottom
and Rayleigh is sharp on the bottom edge and fuzzy on the top. This gives you an approximation
of the distribution shape. If you were to see this noise added to a deterministic binary signal, you
should be able to estimate the signal amplitude divided by the standard deviation which is the
square root of the Signal-to-Noise Ratio (SNR). We can see even more if we were to histogram
the 4 signals (ie., 2 of them are iid Gaussian sequences) as shown in Fig. 4.3.
5
Figure 4.3: Histograms of normalized sequences.