Probability and Statistics
BMAT202L
Module: 2, Random Variable
January 6, 2025 1 / 26
Random variable
Random variable
A random variable (RV) is a function (X : S → R) that associates a real
number with each element in the sample space(S).
Example 1
For example, in a random experiment of tossing two coins, the sample
space be S = {HH, HT , TH, TT }. If is a RV denoting the “number of
heads”, then we have the followings.
X (HH) = 2, X (HT ) = 1, X (TH) = 1, and X (TT ) = 0.
Example 2
Two balls are drawn in succession without replacement from an urn
containing 4 red balls(R) and 3 black balls(B). The possible outcomes
S = {RR, RB, BR, BB}. Then we define a function X from S to real
number R, where X represent the number of red balls for every sample of S
January 6, 2025 2 / 26
Random variable
• If a sample space contains a countable number of possibilities is called
a discrete sample space.
• If a sample space contains an infinite number of possibilities equal to
the number of points on a line segment, it is called a continuous
sample space.
• A real valued function defined on a discrete sample space is called a
discrete random variable.
• A random variable X is said to be continuous if it can take all
possible(integrals as well as fractional) between certain limits.
January 6, 2025 3 / 26
Random variable
Discrete Probability Distributions
A discrete random variable assumes each of its values with a certain
probability. In case of tossing a coin two times, the possible outcomes are
S = {HH, HT , TH, TT }. The variable X , representing the number of
heads in s ∈ S. Now, we define by X : S → R as
X (s1 ) = 2, X (s2 ) = 1, X (s3 ) = 1, X (s4 ) = 0.
January 6, 2025 4 / 26
Random variable
Thus the random variable X and the values of x with the probability
values of x is given below table.
X 0 1 2
1 1 1
P(x)=P(X=x) 4 2 4
The set of ordered pairs (x, P(x)) is called the probability mass function,
probability function, or probability distribution of the discrete random
variable X .
January 6, 2025 5 / 26
Random variable
Probability mass function
The set of ordered pairs (x, P(x)) is a probability mass function,
probability function, or probability distribution of the discrete random
variable X if, for each possible outcome x,
X
P(x) ≥ 0 for all x ∈ X and P(x) = 1.
x∈X
January 6, 2025 6 / 26
Random variable
Problem 3
A shipment of 20 similar laptop computers to a retail outlet contains 3
that are defective. If a school makes a random purchase of 2 of these
computers, find the probability distribution for the number of defectives.
Solution: Let X be a random variable whose values x are the possible
numbers of defective computers purchased by the school. Now,
3C0 × 17C2 68
P(X = 0) = =
20C2 95
3C1 × 17C1 51
P(X = 1) = =
20C2 190
3C2 × 17C0 3
P(X = 2) = =
20C2 190
January 6, 2025 7 / 26
Random variable
Thus, the probability distribution of X is given below table.
X 0 1 2
68 51 3
P(x)=P(X=x) 95 190 190
January 6, 2025 8 / 26
Random variable
Continuous Probability Distributions
• A continuous random variable has a probability 0 of assuming exactly
any of its values. Consequently, its probability distribution cannot be
given in tabular form.
• Let us discuss a random variable whose values are the heights of all
people over 21 years of age.
• Between any two values, say 163.5 and 164.5 centimeters, or even
163.99 and 164.01 centimeters, there are an infinite number of
heights, one of which is 164 centimeters.
January 6, 2025 9 / 26
Random variable
• The probability of selecting a person at random who is exactly 164
centimeters tall and not one of the infinitely large set of heights so
close to 164 centimeters that you cannot humanly measure the
difference is remote, and thus we assign a probability of 0 to the
event.
• This is not the case, however, if we talk about the probability of
selecting a person who is at least 163 centimeters but not more than
165 centimeters tall.
• Now we are dealing with an interval rather than a point value of our
random variable.
January 6, 2025 10 / 26
Random variable
Probability density function
• We shall concern ourselves with computing probabilities for various
intervals of continuous random variables such as
P(a < X < b), P(X ≥ c), and so forth.
• Note that when X is continuous,
P(a < X ≤ b) = P(a < X < b) + P(X = b) = P(a < X < b). That
is, it does not matter whether we include an endpoint of the interval
or not. This is not true, though, when X is discrete.
• A probability density function is constructed so that the area under its
curve bounded by the x-axis is equal to 1 when computed over the
range of X for which f (x) is defined
January 6, 2025 11 / 26
Random variable
• Should this range of X be a finite interval, it is always possible to
extend the interval to include the entire set of real numbers by
defining f (x) to be zero at all points in the extended portions of the
interval.
• In the following Figure, the probability that X assumes a value
between a and b is equal to the shaded area under the density
function between the ordinates at x = a and x = b, and from integral
calculus is given by
Z b
P(a < X < b) = f (x)dx.
a
January 6, 2025 12 / 26
Random variable
January 6, 2025 13 / 26
Random variable
The function f (x) is a probability density function (pdf) for the continuous
random variable X , defined over the set of real numbers, if
Z ∞
f (x) ≥ 0, for all x ∈ R, and f (x)dx = 1.
−∞
Problem 4
Suppose that the error in the reaction temperature, in C, for a controlled
laboratory experiment is a continuous random variable X having the
probability function
x 2 , −1 < x < 2
f (x) = 3
0, otherwise.
Verify that f (x) is a density function and find P(0 < X ≤ 1).
January 6, 2025 14 / 26
Random variable
Solution
R∞
Clearly f (x) ≥ 0. To verify −∞ f (x)dx = 1,
Z ∞ Z −1 Z 2 Z ∞
f (x)dx = f (x)dx + f (x)dx + f (x)dx
−∞ −∞ −1 2
Z 2
= 0+ f (x)dx + 0
−1
3 2
x
=
9 −1
8 (−1)
= −
9 9
8 1
= + = 1.
9 9
January 6, 2025 15 / 26
Random variable
Next,
Z 1
P(0 < X ≤ 1) = f (x)dx
0
Z 1
= f (x)dx
0
1
x3
=
9 0
1
= .
9
January 6, 2025 16 / 26
Random variable
Cumulative distribution function
The cumulative distribution function F (x) of a random variable X with
probability distribution P(x) and probability density function f (x) is
X
P(x = t) if X is discrete
t<x
F (x) = P(X < x) = Z x
f (t)dt if X is continuous
−∞
Let F (x) be a cumulative distribution function of a continuous random
variable X . Then P(a < X < b) = F (b) − F (a) and f (x) = d(Fdx(x)) , if
the derivative exists.
January 6, 2025 17 / 26
Random variable
Problem 5
January 6, 2025 18 / 26
Random variable
Solution
P
For (1), since P(x) is p.m.f, and x P(x) = 1, it follows that
X
P(x) = 1
x
0.1 + k + 0.2 + 2k + 0.3 + k = 1
0.6 + 4k = 1
4k = 0.4
k = 0.1.
January 6, 2025 19 / 26
Random variable
Solution Cont...
January 6, 2025 20 / 26
Random variable
Solution Cont...
January 6, 2025 21 / 26
Random variable
Solution Cont...
January 6, 2025 22 / 26
Random variable
Problem 6
January 6, 2025 23 / 26
Random variable
Problem 7
January 6, 2025 24 / 26
Random variable
Solution:
R 0.4 0.4
For (1), P(X ≤ 0.4) = 0 f (x)dx = x 2 0 = 0.16.
For (3), cumulative distribution F (x) = x 2 .
January 6, 2025 25 / 26
Random variable
Problem 8
January 6, 2025 26 / 26