Continuous Uniform Random Variables:

Continuous Uniform Random Variables are used to model a scenario where a continuous random variable can take values that are equally distributed (with equal probability) in an interval. Uniform distribution is the underlying distribution to model such random variables.

A continuous uniform distribution is denoted by

X \sim \mathcal{U}(a,b) \text{, with a} \leq b .

Here a and b, are limits of the interval over which the distribution is effectively defined.

Probability Density Function

The Probability Density Function (PDF) of the continuous uniform random distribution defined above is given by

This equation indicates that the distribution when used, generates values in the interval (a,b) with equal probability (with probability \frac{1}{b-a})

Continuous Density Function

The Continuous Density Function (CDF) can be derived from the above PDF using the relation


Therefore, the CDF of the continuous uniform distribution is given by,

Plotting the PDF and CDF,

Uniform Distribution (Continous)

PDF and CDF of Continuous Uniform Distribution (Continous)

Discrete Uniform Random Variable:

Discrete Uniform Random Variables are used to model a scenario where a discrete random variable can take values that are equally distributed (with equal probability) in an interval. The underlying discrete uniform distribution is denoted by
X \sim \mathcal{U}(\mathcal{S})

Where \mathcal{S} is a finite set of discrete points on the real line. Meaning that each element in the finite set are equally likely.

Example:

“Rolling a fair die” can be considered as an experiment to generate uniform integers in the range 1 to 6. Since rolling of a fair die give only one of the six possible integer values (1,2,3,4,5,6), it is an experiment that generates discrete values. Since all the values in a fair die are equally likely (with probability of getting each value =1/6) it can be modelled using a discrete uniform distribution.

For a die, the set \mathcal{S} can take values {1,2,3,4,5,6}

Probability Mass Function (PMF):

If , then the due to the definition of uniform distribution, each element in the set are equally probable. Therefore,

Then the PMF can be given by,

For rolling a fair die, the PMF simplifies as follows

The PMF and CDF for a discrete uniform random distribution is shown below

PMF and CDF of discrete uniform random variable

PMF and CDF of Discrete Uniform Distribution

Generating Uniform Random Numbers in Matlab:

Generating Continuous Uniform Random Numbers:

In Matlab “rand” function is used to generate continous uniform random numbers in the range [0,1].
rand function is used to pick any number in the interval [0,1] in which all the numbers in the interval are equally likely.

rand(n,m) will generate a matrix of size nxm. A trial run at my system gave the following results

To generate a random number in the interval [a,b] one can use the following code

a + (b-a)*rand(n,m); %Here nxm is the size of the output matrix

For example, to generate a matrix of size 3×4 using uniform distribution in the interval [2,10]

Testing Uniformity:

To test whether the numbers generated by the uniform distribution are uniform in the interval [a,b], one has to generate very large number of values using the rand function and then plot the histogram

Testing the uniformity of rand function in the interval [2,10]

The histogram plot given below shows that the numbers in the range [2,10] are generated with almost equal probability.

Histogram of Uniform Distribution

Histogram of Uniform Distribution

Generating Discrete Uniform Random Numbers:

The same “rand” function can be used to generate discrete random numbers that follow discrete uniform distribution. The code to generate uniformly distributed discrete numbers from the set is given below.

To model rolling of a fair die, the sample space . A roll of the die should generate a number from the sample space with equal probability. This single event can be modelled in matlab as

(The uniformity test for discrete random numbers can be done using the same code given above in the previous section)

Note:There is one more function in Matlab called “randn”. This function is used to generate random numbers that are normally distributed.

Reference:

[1] Matlab Documentation entry on generating Uniformly distributed pseudorandom numbers using rand function

See Also:

[1] Introduction to Random Variables, PDF and CDF
[2] Chi-Squared distribution
[3] Derivation of Error Rate Performance of an optimum BPSK receiver in AWGN channel
[4] Eb/N0 Vs BER for BPSK over Rician Fading Channel
[5] BER Vs Eb/N0 for QPSK modulation over AWGN
[6] BER Vs Eb/N0 for 8-PSK modulation over AWGN
[7] Simulation of M-PSK modulation techniques in AWGN channel
[8] Performance comparison of Digital Modulation techniques

Recommended Books

More Recommended Books at our Integrated Book Store

Avatar of Mathuranathan

Mathuranathan

– Founder and Author @ gaussianwaves.com which has garnered worldwide readership. He is a masters in communication engineering and has 7 years of technical expertise in channel modeling and has worked in various technologies ranging from read channel design for hard drives, GSM/EDGE/GPRS, OFDM, MIMO, 3GPP PHY layer and DSL.
He also specializes in tutoring on various subjects like signal processing, random process, digital communication etc..,He can be contacted at support@gaussianwaves.com

Your Thoughts ?

comments