Random Variable

Ushmita Saha
Analytics Vidhya
Published in
4 min readNov 6, 2019

One of the basic concepts of statistic is a Random Variable. So, what is Random Variable? Random variable links the outcome of an event to a number. Let’s take an example. X is variable which takes the value 0 if it rains or 1 otherwise.

The random variable under statistics is quite different from the variable under algebra. Under algebra the variable cannot take more than one value at a time whereas random variable under statistics can take values from entire set of values. Each value under random variable has probability attached to it.

Type of Random Variable

There are two basic kind of random variable-

a) Discrete Random Variable

b) Continuous Random Variable

a) Discrete Random Variable-In case of discrete random variable the values associated with the outcome can be list down. It has specific set of values.

b) Continuous Random Variable-In case of continuous random variable the variable takes a range of values which can be finite as well as infinite.

Construction of Probability Distribution of Random variable-

The probability distribution of random variable describes how the probability is distributed over the outcomes of random variable.

Let’s take an example. Let’s assume that you love playing badminton. You have been practicing it quite often. Below given the data of your practice sheet for 8 days. Your practice is segregated in 3 times in a day. “No” signifies that badminton is not played and “Yes” signifies that badminton is played. X is a random variable which signifies the number of times badminton is played.

P(X=0) =1/8

P(X=1) = 3/8

P(X=2) = 3/8

P(X=3) = 1/8

Plotting the probability for X (random variable) in Y-axis and the X value or outcomes in X-axis we get the probability distribution of the discrete random variable X. The probability distribution of discrete random variable is known as Probability mass function.

Note that to get accurate probability model the sum of the probability should be equal to one and the probability should not be negative.

Some example of discrete probability distribution is Bernoulli distribution, Binomial distribution, Poisson distribution etc.

Note that in case of discrete random variable, the probability distribution is defined by probability mass function.

In case of continuous random variable, the probability distribution is defined by probability density function. The density function does not directly give the probability of random variable taking a specific value. By taking the integral over the interval we get the probability for the given interval under continues random variable. For continuous random variable there is no point in taking each value and count its probability as there are huge range of values for it.

For example, we have data on the weight which is a continuous variable so finding the probability of each point would not make much sense. To find the probability the interval should be taken. The data has been shown in the histogram.

To get the probability of the value the integral within the interval should be taken. For example, if we want to know the probability of weight falling within 77 and 29 than the probability density function will be defined as-

The function f(x) is called the probability density function (pdf).

The probability density function f(x) of a continuous random variable is the analogue of the probability mass function p(x) of a discrete random variable. Here are two important differences:

1. Unlike p(x) which is a probability mass function, the pdf f(x) is not a probability. You must integrate it to get probability.

2. Since f(x) is not a probability, there is no restriction that f(x) be less than or equal to 1.

Some examples of continuous probability distributions are normal distribution, exponential distribution, beta distribution, etc.

Hope that my article helped you to get more clear idea about the random variable. I will be continuing my article further with cumulative distribution function and varies kinds of distribution which are commonly used.

Thank for reading my article. Please do feel free to share your valuable feedback on ushmi2015@gmail.com .

If you would like to read my future posts then simply ‘Connect’ or ‘Follow’.

--

--

Ushmita Saha
Analytics Vidhya

Senior Data Analyst at UST Global(Data Science and Analytics Division)