Single - Random - Variable
Single - Random - Variable
Introduction
For a discrete r.v. X with possible values x1 , x2 , . . . , xn , a probability mass function such
that
1. P (X) ≥ 0
P
2. P (X) = 1.
1
1.1 Mean (Expected Value)
1.1 Mean (Expected Value)
For a discrete r.v. X with possible values x1 , x2 , . . . , xn and probability mass function P (X =
xi ) = pi where i = 1, 2, . . . , n, the mean or expected value (E(X)) is calculated as:
n
X
µ = E(X) = xi · p i .
i=1
1. E(a) = a E(2) = 2
1.2 Variance
The variance (V ar(X)) of a random variable X can be calculated using the formula:
Pn
where E(X 2 ) = i=1 x2i · pi .
Properties of Variance
1. V ar(a) = 0 V ar(4) = 0
p
σ= V (x)
2
1.2 Variance
Example 1
Consider an experiment of tossing a fair coin three times. Let X be the random variable
representing the number of heads obtained. Find the following:
1. Distribution of X
3. V (X) and σ
4. P (X) ≤ 1 and P (X = 3)
Solution
2. Mean: To find the mean (µ = E(X)) of a random variable X with values 0, 1, 2, 3 and
respective probabilities 81 , 38 , 38 , 81 , it is calculated as:
1 3 3 1
µ = E(X) = 0 · + 1 · + 2 · + 3 · = 1.5.
8 8 8 8
So,
E(2X + 10) = 2 × (1.5) + 10 = 13.
3
1.2 Variance
2
We need now solve E(X ) as given:
1 3 3 1
+ 12 · + 22 · + 32 ·
E(X 2 ) = 02 ·
8 8 8 8
3 12 9
=0+ + + = 3.
8 8 8
p √
The standard deviation σ = V ar(X) = 0.75.
4. Probabilities:
Example 2
Consider a random variable X with values 0, 1, 2 and their respective probabilities given in
the table:
X 0 1 2
P(X = x) 0.2 0.7 k
4
1.2 Variance
Solution
P
1. As long as P (X) is a probability mass function that holds the rule: P (X) = 1, we can
say that:
P (X = 0) + P (X = 1) + P (X = 2) = 1
= 0.2 + 0.7 + k = 1.
Therefore, k = 0.1
X
E(X) = x · P (X = x)
Variance:
To calculate the variance of a discrete random variable X, firstly to find out E(X 2 ):
X
E(X 2 ) = x2 · P (X = x)
5
1.2 Variance
Example 3
Let X be a discrete random variable with the following probability mass function (pmf):
kx if x = 1, 2, 3
P (X) =
0 otherwise
1. The constant k.
Solution
1. Constant k:
Since P (X) is a probability mass function (pmf), it must satisfy the condition that the sum
of probabilities for all possible values equals 1:
3
X
P (X) = k · 1 + k · 2 + k · 3 = 1
x=1
= k · 6 = 1.
3
X 1 2 3 1 4 9 14 7
E(X) = x · P (X = x) = 1 · +2· +3· = + + = =
x=1
6 6 6 6 6 6 6 3
X 1 2 3 1 8 27 36
E(X 2 ) = x2 · P (X = x) = 12 · + 2 2 · + 32 · = + + = = 6.
6 6 6 6 6 6 6
6
Therefore, the variance of X is:
2
2 2 7 49 5
Var(X) = E(X ) − [E(X)] = 6 − =6− = .
3 9 9
3. Calculations
7
E(3X + 4) = 3 · + 4 = 7 + 4 = 11
3
5 20
V (2X + 5) = 4 · =
9 9
For a continuous random variable X with a probability density function (pdf) denoted as
f (x) such that:
R∞
2. −∞
f (x) dx = 1.
The CDF for a continuous random variable X with probability density function f (x) is
defined as:
Z x
F (x) = P (X ≤ x) = f (x) dx.
−∞
7
2.1 Mean (Expected Value)
2.1 Mean (Expected Value)
For a continuous random variable X with probability density function f (x), the mean or
expected value (E(X)) is calculated as:
Z ∞
µ = E(X) = x · f (x) dx.
−∞
2.2 Variance
The variance (V ar(X)) of a continuous random variable X can be calculated using the
formula:
Var(X) = E(X 2 ) − (E(X))2 ,
R∞
where E(X 2 ) = −∞
x2 · f (x) dx.
Example 1
Let X be a continuous random variable with the following probability density function (pdf):
kx if 0 ≤ x ≤ 2
f (x) =
0 otherwise
3. F (x).
Solution
1. The constant k:
8
2.2 Variance
To find k, we’ll use the fact that the total area under the probability density function over
the entire range of possible values must be equal to 1:
Z 2
kx dx = 1
0
k·2−0=1
1
Therefore, the constant k = .
2
Here,
Z 2 3 2
1 x 4
µ= x · x dx = = .
0 2 6 0 3
Where:
Z 2 4 2
2 1
2 x 16
E(X ) = x · x dx = = = 2.
0 2 8 0 8
16 2
V ar(X) = 2 − = .
9 9
3. F (x):
The cumulative distribution function (CDF) for the continuous random variable X can be
calculated as:
x x
x2
Z Z
x
F (x) = P (X ≤ x) = f (x) dx = dx = .
0 0 2 4
9
2.2 Variance
4. Probabilities:
1 1
P (0 < X ≤ 1) = F (1) − F (0) = −0= .
4 4
1 1
x2
Z Z
x 1
f (x) dx = dx = = .
0 0 2 4 4
Same wise,
4 1 3
P (X > 1) = P (1 < X ≤ 2) = F (2) − F (1) = − = .
4 4 4
R2
Here, we also can solve it by doing 1
f (x) = 34 .
Example 2
Let X be a continuous random variable with the following probability density function (pdf):
kx(x + 1) if 0 ≤ x ≤ 1
f (x) =
0 otherwise
2. µ and V (3X).
3. F (x).
4. P (0 < X ≤ 0.5).
10
2.2 Variance
Solution
1. The constant k:
1
1 1
x 3 x2
Z Z
2 5
kx(x + 1) dx = k (x + x) dx = k( + ) =k =1
0 0 3 2 6
0
6
k= .
5
2. µ and V (3x):
1 1 1
6 x4 x3
Z Z
6 6 3 2 7
µ= x · x(x + 1) dx = x + x dx = + = .
0 5 5 0 5 4 3 0 10
The variance:
1 1 1
6 x5 x4
Z Z
2 2 6 6 4 3 6 1 1 27
E(X ) = x · x(x + 1) dx = x + x dx = + = + = .
0 5 5 0 5 5 4 0 5 5 4 50
27 49 1
V (X) = E(X 2 ) − (E(X))2 = − = .
50 100 20
Therefore,
1 9
V (3x) = 9 · = .
20 20
3. F (x):
Z x Z x
6
F (x) = x(x + 1) dx
f (x) dx =
0 0 5
x
6 x 2 6 x3 x2 6 x3 x2
Z
F (x) = x + x dx = + = + .
5 0 5 3 2 0 5 3 2
4. P (0 < X ≤ 0.5):
(0.5)3 (0.5)2
6 1
P (0 < X ≤ 0.5) = F (0.5) − F (0) = + = .
5 3 2 5
11
2.2 Variance
Example 3
Solution
1. The value of c:
2 2
2x3 2 · 23
Z
2 2 2
c(4x − 2x ) dx = c 2x − = c (2 · 2 ) −
0 3 0 3
16 24 16 8
= c(8 − ) = c( − ) = c( ) = 1.
3 3 3 3
3
c= .
8
2. Find P (X > 1)
2 2
3 2 2x3
Z Z
2 3 2
P (X > 1) = f (x) dx = (4x − 2x ) dx = 2x −
1 8 1 8 3 1
3 16 2 1
= (8 − ) − (2 − ) = .
8 3 3 2
12
2.2 Variance
Exercises
i. Let X be a continuous random variable with the following probability density function
(pdf):
kx2 if 1 ≤ x ≤ 3
f (x) =
0 otherwise
3. F (x).
4. P (2 < X ≤ 3).
ii. Let X be a continuous random variable with the following probability density function
(pdf):
x
k
if 0 ≤ x ≤ 2
f (x) =
0 otherwise
3. F (x).
13