Random Variable in Probability
What happens when you toss a coin or roll a dice? In probability, we use a “random variable” to describe these uncertain outcomes. But what does it really mean, and how does it work? Let’s find out.
If you are an aspiring data scientist or statistician, one of the first questions is what random variables are and how they are associated with probability distribution. We will discuss the concept of a random variable, its type, and its association with the random variable.
Later, we will also discuss how to calculate the mean and variance of a discrete and continuous random variable.
So, let’s start with the definition of Random Variables in Probability.
Table of Content
Best-suited Statistics for Data Science courses for you
Learn Statistics for Data Science with these high-rated online courses
What is a Random Variable in Probability?
Random variables are the numerical descriptions of the outcomes of any statistical experiment. In simple terms, a random variable is a rule that associates a numerical value with each outcome in a sample space of an experiment.
Generally, random variables are denoted by X or Y.
Let’s take an example to understand better what random variables are.
Suppose that you toss two coins, then the sample space of the experiment is the set of all possible outcomes, which are:
- HH (Heads on the both the coins)
- HT (Head on the first coin and Tail on the second coin)
- TH (Tail on the first coin and Head on the second coin)
- TT (Tails on both the coins)
Here, the probability of each outcome will be equal since the chance of getting head or getting tail while tossing a coin will always be 50%, i.e.,
P({X=HH}) = P({X=HT}) = P({X=TH}) = P({X=TT}) = 1/4
In the case of tossing two coins, the possible values of the random variable are the number of heads (or tails) that appear, i.e., 0, 1, and 2.
- HH (or TT) – When both the coins show Head (or Tails), the value will be 2.
- HT or TH – When one coin shows a head and another shows a tail, the value will be 1.
- TT – When both coins show Tail (or Head), the value will be 0.
In the above example, the value of the random variable is discrete, i.e., 0, 1, and 2, but what if the values of a random variable are continuous?
Based on the values a random variable can take, they are classified into Discrete Random and Continuous Random.
Let’s explore both types of random variables.
Types of Random Variables
Continuous Random Variable
A random variable that can take infinite possible values is known as a continuous random variable. The set of all the possible values of a continuous random variable is an interval of real numbers.
Example of continuous random variable includes
- heights of students
- weight of employees
- amount of rainfall.
Continuous random variables are used to estimate mean and standard deviation, hypothesis testing, and regression analysis.
Discrete Random Variable
A random variable that can take only a countable number of distinct values, such as 0,1,2,3,4…. is known as a discrete random variable.
Example of discrete random variable includes:
- The number of heads on tossing a coin.
- Getting a king from the shuffled deck of cards.
- The number of successes in the Bernoulli trials.
- The number of cars passing through a red light in an hour.
Discrete Random Variables are used to calculate the probability of events, statistical interference, and machine learning.
Note: If a random variable can take only a finite number of distinct values, they must be discrete.
Random Variable and Probability Distribution
A probability distribution of a random variable is a list of all possible outcomes with the corresponding probability values.
or
The probability distribution for a random variable shows how the probabilities are distributed over the values of the random variable.
Example: The probability distribution for tossing two coins is given as
Outcome of the toss | HH | HT | TH | TT |
Probability | 1/4 | 1/4 | 1/4 | 1/4 |
There are types of probability distribution based on the types of random variables.
- Discrete Probability Distribution
- Continuous Probability Distribution
If the random variable is a discrete random variable, then its probability distribution is called Discrete Probability Distribution.
Types of Discrete Probability Distribution
- Binomial Probability Distribution
- Poisson Probability Distribution
- Bernoulli Probability Distribution
If the random variable is a continuous random variable, then its probability distribution is called Continuous Probability Distribution.
Types of Continuous Probability Distribution
- Uniform Probability Distribution
- Normal Probability Distribution
- Exponential Probability Distribution
Note:
- The function that represents the discrete probability distribution is known as the Probability Mass Function.
- The function representing the continuous probability distribution is the Probability Density Function.
- The value of the probability distribution always lies between 0 and 1.
Must Read: PDF vs CDF: Difference Between Probability Density Function and Cumulative Distribution Function
Expected Value and Variance of a Random Variables
Discrete Random Variable
- Expected Value or Mean: E[X] = Σ x * P(X=x)
- Variance: Var[X] = Σ (x-u)^2 * P (X = x)
where
X: Discrete Random Variable
P(X = x): Probability Mass Function
u: mean
Continuous Random Variable
- Expected Value or Mean: E[X] = ∫ x * P(X=x)
- Variance: Var[X] = ∫ (x-u)^2 * P (X = x)
where
X: Continuous Random Variable
P(X = x): Probability Density Function
u: mean
Difference Between Continuous Random Variable and Discrete Random Variable
Continuous Random Variable | Discrete Random Variable | |
Definition | It can take any value within a specified range. | It can take only distinct, separate values. |
Examples | Height of a person, temperature, time. | Number of cars in a parking lot, dice roll outcome. |
Probability Distribution | Described by a Probability Density Function (PDF). | Described by a Probability Mass Function (PMF). |
Probability of a Single Outcome | Always zero, as infinite possibilities exist within a range. | It can be calculated directly from the PMF. |
Graphical Representation | Represented by a curve on a graph. | Represented by individual points or bars on a graph. |
Calculation of Probability | Calculated using integrals over a range of values. | Calculated by summing the probabilities of individual outcomes. |
Random Variable Practice Problem
Here is a list of 10 practice problems to master the concept of random variables in probability.
- A fair coin is tossed 10 times. What is the probability of getting exactly 5 heads?
- A die is rolled 6 times. What is the probability of getting a 6 at least once?
- The heights of 100 randomly selected people are normally distributed with a mean 170 cm and a standard deviation 5 cm. What is the probability that a randomly selected person is taller than 175 cm?
- The amount of rainfall in a certain city follows a Poisson distribution with a mean 10 mm per day. What is the probability that there will be more than 12 mm of rainfall in a day?
- The number of customers arriving at a bank per hour follows a Poisson distribution with a mean 5. What is the probability that there will be at least 3 customers arriving in the next hour?
- Let X be the number of heads in 100 coin flips. Find the probability distribution of X.
- Let Y be the time it takes for a light bulb to burn out. Find the probability density function of Y.
- Let Z be the score of a student on a test. Find the mean and variance of Z.
- Let W be the amount of money won or lost in a game of roulette. Find the expected value of W.
- Let X be the height of a randomly selected person. Find the cumulative distribution function of X.
Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio