# The Uniform Random Variable

The uniform random variable is one of the most simplest random variables to learn. It may not seem like much but it does contain some nice properties.

What is a Uniform Random Variable?

A uniform random variable is a random variable which takes on values from parameters to (inclusive). If the random variable is uniform then we denote it as .

(Note that we deal with the continuous uniform random variable and not the discrete case.)

The continuous probability distribution function (pdf) of a uniform random variable is:

If the parameters and are 0 and 1 respectively then X is a standard uniform random variable denoted as U. It would be denoted as . The continuous probability distribution of a standard uniform random variable is just .

The image below shows the (theoretical) continuous probability distribution for the uniform random variable.

Source: https://www.probabilitycourse.com/images/chapter4/PDF-Uniform_b.png

The Cumulative Distribution Function (CDF)

The Cumulative Distribution Function or the CDF is the probability that a real-valued random variable with a given probability distribution is less than or equal to a quantity . It is often denoted by .

The CDF of a uniform random variable is . for .

Proof

For the case of a standard uniform random variable, substituting and yields the CDF as .

Generating/Simulating/Sampling Uniform Random Variables

Generating a uniform random variable from 0 to 1 (not including 1) is quite simple in Microsoft Excel. The function is =RAND().

To generate or simulate a uniform random variable in the free statistical programming language R, we use the runif function as follows:

The in runif is the number of simulations in which the user enters. The minimum of 0 and the maximum of 1 can be altered to create a different uniform random variable.

Examples

In these two examples, I am simulating/generating standard uniform random variables from 0 to 1 in the statistical program R.

Case One (Running 1000 simulation trials):

Case Two (Running 1 Million Simulation Trials):

Comparing the two images above, increasing the number of trials makes our sample probability distribution become closer to the rectangle shape as in the first image above.