Random Variable
Random variable is a variable that is used to quantify the outcome of a random experiment. As data can be of two types, discrete and continuous hence, there can be two types of random variables. A discrete random variable can take on an exact value while the value of a continuous random variable will fall between some particular interval.
Probability distributions are used to show how probabilities are distributed over the values of a given random variable. In this article, we will learn the definition of a random variable, its types and see various examples.
What is a Random Variable?
A random variable is a variable that can take on many values. This is because there can be several outcomes of a random occurrence. Thus, a random variable should not be confused with an algebraic variable. An algebraic variable represents the value of an unknown quantity in an algebraic equation that can be calculated. On the other hand, a random variable can have a set of values that could be the resulting outcome of a random experiment.
Random Variable Definition
A random variable can be defined as a type of variable whose value depends upon the numerical outcomes of a certain random phenomenon. It is also known as a stochastic variable. Random variables are always real numbers as they are required to be measurable.
Random Variable Example
Suppose 2 dice are rolled and the random variable, X, is used to represent the sum of the numbers. Then, the smallest value of X will be equal to 2 (1 + 1), while the highest value would be 12 (6 + 6). Thus, X could take on any value between 2 to 12 (inclusive). Now if probabilities are attached to each outcome then the probability distribution of X can be determined.
Types of Random Variables
Random Variables can be divided into two broad categories depending upon the type of data available. These are given as follows:
- Discrete random variable
- Continuous random variable
A probability mass function is used to describe a discrete random variable and a probability density function describes a continuous random variable. The upcoming sections will cover these topics in detail.
Discrete Random Variable
A discrete random variable is a variable that can take on a finite number of distinct values. For example, the number of children in a family can be represented using a discrete random variable. A probability distribution is used to determine what values a random variable can take and how often does it take on these values. Some of the discrete random variables that are associated with certain special probability distributions will be detailed in the upcoming section.
Binomial Random Variable
A random variable that represents the number of successes in a binomial experiment is known as a binomial random variable. A binomial experiment has a fixed number of repeated Bernoulli trials and can only have two outcomes, i.e., success or failure. The number of trials is given by n and the success probability is represented by p.
A binomial random variable, X, is written as \(X\sim Bin(n,p)\)
The probability mass function is given as \(P(X = x) = \binom{n}{x}p^{x}(1-p)^{n-x}\), where x is the value that X is evaluated at.
Geometric Random Variable
A geometric random variable is a random variable that denotes the number of consecutive failures in a Bernoulli trial until the first success is obtained. The probability of success in a Bernoulli trial is given by p and the probability of failure is 1 - p.
A geometric random variable is written as \(X\sim G(p)\)
The probability mass function is P(X = x) = (1 - p)x - 1p
Bernoulli Random Variable
A Bernoulli random variable is the simplest type of random variable. It can take only two possible values, i.e., 1 to represent a success and 0 to represent a failure.
A Bernoulli random variable is given by \(X\sim Bernoulli(p)\), where p represents the success probability.
Probability mass function: P(X = x) = \(\left\{\begin{matrix} p & if\: x = 1\\ 1 - p& if \: x = 0 \end{matrix}\right.\)
Poisson Random Variable
A Poisson random variable is used to show how many times an event will occur within a given time period. These events occur independently and at a constant rate. The parameter of a Poisson distribution is given by \(\lambda\) which is always greater than 0.
A Poisson random variable is represented as \(X\sim Poisson(\lambda )\)
The probability mass function is given by P(X = x) = \(\frac{\lambda ^{x}e^{-\lambda }}{x!}\)
Continuous Random Variable
A random variable that can take on an infinite number of possible values is known as a continuous random variable. Such a variable is defined over an interval of values rather than a specific value. An example of a continuous random variable is the weight of a person. The probability that a continuous random variable takes on an exact value is 0 thus, a probability density function is used to describe such a variable. Some commonly used continuous random variables are given below.
Exponential Random Variable
An exponential random variable is used to model an exponential distribution which shows the time elapsed between two events. The parameter of an exponential distribution is given by \(\lambda\).
An exponential random variable is given as \(X\sim Exp(\lambda )\)
The probability density function is f(x) = \(\left\{\begin{matrix} \lambda e^{-\lambda x} & x\geq 0\\ 0 & x< 0 \end{matrix}\right.\)
Normal Random Variable
A random variable that follows a normal distribution is known as a normal random variable. The parameters of a normal random variable are the mean \(\mu\) and variance \(\sigma ^{2}\).
A normal random variable is expressed as \(X\sim (\mu,\sigma ^{2} )\)
The probability density function is f(x) = \(\frac{1}{\sigma \sqrt{2\Pi }}e^{\frac{-1}{2}(\frac{x-\mu }{\sigma })^{2}}\)
Mean of a Random Variable
The average value of a random variable is called the mean of a random variable. The mean is also known as the expected value. It is generally denoted by E[X]. where X is the random variable. The mean or expected value of a random variable can also be defined as the weighted average of all the values of the variable. The formulas for the mean of a random variable are given below:
- Mean of a Discrete Random Variable: E[X] = \(\sum xP(X = x)\). Here P(X = x) is the probability mass function.
- Mean of a Continuous Random Variable: E[X] = \(\int xf(x)dx\). f(x) is the probability density function
Variance of a Random Variable
The variance of a random variable can be defined as the expected value of the square of the difference of the random variable from the mean. The variance of a random variable is given by Var[X] or \(\sigma ^{2}\). If \(\mu\) is the mean then the formula for the variance is given as follows:
- Variance of a Discrete Random Variable: Var[X] = \(\sum (x-\mu )^{2}P(X=x)\)
- Variance of a Continuous Random Variable: Var[X] = \(\int (x-\mu )^{2}f(x)dx\)
Related Articles:
Important Notes on Random Variable
- A random variable is a variable that is used to denote the numerical outcome of a random experiment.
- Discrete and continuous random variables are types of random variables.
- A discrete random variable can take an exact value. Examples are a binomial random variable and a Poisson random variable.
- The value of a continuous random variable falls between a range of values. Examples include a normal random variable and an exponential random variable.
- The mean of a random variable if given by \(\sum xP(X = x)\) or \(\int xf(x)dx\).
- The variance of a random variable is given by \(\sum (x-\mu )^{2}P(X=x)\) or \(\int (x-\mu )^{2}f(x)dx\).
Examples on Random Variable
-
Example 1: What is the expected value of a dice roll?
Solution: The random variable, X, can take on values from 1 to 6. The probability of occurrence of each value is 1 / 6.
Using the formula, E[X] = \(\sum xP(X = x)\)
E[X] = 1·(1 / 6) + 2·(1 / 6) + 3·(1 / 6) + 4·(1 / 6) + 5·(1 / 6) + 6·(1 / 6) = 21 / 6
Answer: E[X] = 21 / 6 -
Example 2: If X is a discrete random variable with a probability mass function given as
\(\left\{\begin{matrix} 0.2 & x=0.1\\ 0.3& x=0.2\\ 0.1& x=0.3\\ 0.4& x=0.4\\ 0 & otherwise \end{matrix}\right.\)
Find P(X < 0.4)
Solution: P(X < 0.4) = P(X = 0.1) + P(X = 0.2) + P(X = 0.3)
P(X < 0.4) = 0.2 + 0.3 + 0.1 = 0.6
Answer: P(X < 0.4) = 0.6 -
Example 3: Compute the mean of a random variable that follows a distribution given by
f(x) = \(\left\{\begin{matrix} (p+1)x^{p} & 0\leq x\leq 1\\ &\\0& otherwise \end{matrix}\right.\)
where p > -1
Solution: The formula for expectation is given as E[X] = \(\int xf(x)dx\)
E[X] = \(\int_{0}^{1}(p+1)x^{p+1}dx\)
E[X] = \([\frac{(x^{p+2})(p+1)}{p+2}]_{0}^{1}\)
E[X] = (p + 1) / (p + 2)
FAQs on Random Variable
What is a Random Variable in Statistics?
A random variable is a type of variable that represents all the possible outcomes of a random occurrence. A probability distribution represents the likelihood that a random variable will take on a particular value.
What Is The Difference Between A Variable And A Random Variable?
An algebraic variable in an algebraic equation is a quantity whose exact value can be determined. A random variable is a variable that can take on a set of values as the result of the outcome of an event.
What Are The Types of a Random Variable?
There are two types of random variables. These are discrete random variables and continuous random variables. A discrete random variable can take on a distinct value while a continuous random variable is defined for an interval of values.
What is a Continuous Random Variable Example?
A continuous random variable is usually used to represent a quantity such as a measurement. Examples include height, weight, the time required to run a mile, etc. Normal and exponential random variables are types of continuous random variables.
What is a Discrete Random Variable Example?
A discrete random variable is used to denote a distinct quantity. For example, the number of defective light bulbs in a box, the number of patients at a clinic, etc., can all be represented by discrete random variables. Binomial, Geometric, Poisson random variables are examples of discrete random variables.
What is the Mean of a Random Variable?
The formulas for the mean of a random variable are given as follows:
- Mean of a Discrete Random Variable: E[X] = \(\sum xP(X = x)\).
- Mean of a Continuous Random Variable: E[X] = \(\int xf(x)dx\).
What is the Variance of a Random Variable?
The formulas for the variance of a random variable are given as follows:
- Variance of a Discrete Random Variable: Var[X] = \(\sum (x-\mu )^{2}P(X=x)\)
- Variance of a Continuous Random Variable: Var[X] = \(\int (x-\mu )^{2}f(x)dx\)
visual curriculum