Lecture Note L3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Ch 02: 1

Probability and Statistic


Chapter 3
Random Variables and Probability
Distributions

Fall 2023
Ch 02: 2
Probability theory
Random variables

A random variable is a function that associates a real number with


each element in the sample space.

Suppose that to each point of a sample space we assign a number. We


then have a function defined on the sample space.
This function is called a random variable.
It is usually denoted by a capital letter such as X or Y. In general, a
random variable has some specified physical, geometrical, or other
significance.

Fall 2023
Ch 02: 3
Probability theory
Random variables
EXAMPLE 2.1

Suppose that a coin is tossed twice.


Let X represent the number of heads that can come up.

The sample space is S={HH, HT, TH, TT}.


With each sample point we can associate a number for X as shown
in the table below.

Fall 2023
Ch 02: 4
Probability theory
Random variables
Thus, for example, in the case of HH (i.e., 2 heads), X = 2
while for TH (1 head), X = 1. It follows that X is a random
variable.

Fall 2023
Ch 02: 5
Probability theory
Random variables

In an experiment a number is often attached to each outcome.


S
s X(s) R

Definition:
A random variable X is a function defined on S, which takes
values on the real axis
X: S → R
Sample space Real numbers

Fall 2023
Ch 02: 6
Probability theory
Random variables
Example:
Random variable Type
Number of eyes when rolling a dice discrete 
The sum of eyes when rolling two dice discrete 
discrete 
counting
Number of children in a family

Age of first-time mother discrete 
Time of running 5 km continuous 

Amount of sugar in a coke continuous  measure
Height of males continuous 

Discrete: can take a finite number of values or an


infinite but countable number of values.
Continuous: takes values from the set of real numbers.

Fall 2023
Ch 02: 7
Discrete random variable
Probability function

Definition:
Let X : S → R be a discrete random variable.

The function f(x) is a probability mass function for X, if


1. f(x)  0 for all x
2.  f ( x ) = 1
x

3. P(X = x) = f(x),
where P(X=x) is the probability for the outcomes sS : X(s) = x.

Fall 2023
Ch 02: 8
Discrete random variable
Probability function
Example: Find the Probability function for the number of
heads when flipping three coins. Let X : # heads.
Solution: S={HHH, HHT, HTH, THH, TTH, THT, HTT, TTT}
X : S → {0,1,2,3}
Outcome Value of X Probability function
TTT x=0 f(0) = P(X=0) = 1/8
HTT, TTH, THT x=1 f(1) = P(X=1) = 3/8
HHT, HTH, THH x=2 f(2) = P(X=2) = 3/8
HHH x=3 f(3) = P(X=3) = 1/8

Notice! The definition of a probability function is fulfilled:


1. f(x) 0
2.  f(x) = 1
3. P(X=x) = f(x)

Fall 2023
Ch 02: 9
Discrete random variable
Probability function
Example:
A pair of fair dice is tossed. Let X assign to each point (a,b) in S the
maximum of its numbers, i.e. X(a,b) = max (a,b). Find f(x).

Solution:
We obtain the sample space S consisting of the 36 ordered pairs of
numbers between 1 and 6:

S = {(1, 1), (1,2), ..,(6,6) }

Then X is a random variable

X : S → {1, 2, 3, 4, 5, 6}

Fall 2023
Ch 02: 10
Discrete random variable
Probability function
We compute the distribution f (x):

f(1) = P(X=1) = P({(1,1)}) =1/36


f(2) = P(X=2) = P({(2,1),(2,2),(1,2)}) = 3/36
f(3) = P(X =3) = P({(3,1), (3,2),(3,3),(2,3),(1,3)}) = 5/36
f(4) = P(X =4) = P({(4,1),(4,2),(4,3),(4,4), (3,4), (2,4), (1,4)}) = 7/36
Similarly
f(5) = P(X =5) = 9/36
f(6) = P(X =6) = 11/36

This information is put in the form of a table as follows:

x 1 2 3 4 5 6
f(x) 1/36 3/36 5/36 7/36 9/36 11/36

Fall 2023
Ch 02: 11
Discrete random variable
Probability function
The graph of the distribution function f(x) with x is:

Fall 2023
Ch 02: 12
Discrete random variable
Probability function
Example:
Now let Y assign to each point (a,b) in S the sum of its numbers, i.e.
Y(a,b) = a + b. Find f(y).

Solution:
S = {(1, 1), (1,2), ..,(6,6) }
Then Y is a random variable

Y : S → {2, 3, 4, 5, 6, 7, 8, 9,10,11,12}
This information is put in the form of a table as follows:

y 2 3 4 5 6 7 8 9 10 11 12
f(y) 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36

Fall 2023
Ch 02: 13
Discrete random variable
Probability function
The graph of the distribution function f(y) with y is:

Fall 2023
Ch 02: 14
Discrete random variable
Probability function
Example:
A coin weighted so that P(H) = 2/3 and P(T) = 1/3 is tossed three
times. Let X be the random variable which assigns to each point in S
the largest number of successive heads which occurs. Find the
distribution function f(x).

Solution:

Then X is a random variable


X : S → {0, 1, 2, 3}
The sample space S = (HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}

Fall 2023
Ch 02: 15
Discrete random variable
Probability function
The probabilities of the points in S are as follows:

Outcome (s) P(s)


HHH 2/3*2/3*2/3= 8/27
HHT 2/3*2/3*1/3= 4/27
HTH 2/3*1/3*2/3= 4/27
HTT 2/3*1/3*1/3= 2/27
THH 1/3*2/3*2/3= 4/27
THT 1/3*2/3*1/3= 2/27
TTH 1/3*1/3*2/3= 2/27
TTT 1/3*1/3*1/3= 1/27

Fall 2023
Ch 02: 16
Discrete random variable
Probability function
Assign a number for each out come, i.e. Get the values of X:

Outcome (s) X(s)


HHH 3
HHT 2
HTH 2
HTT 1
THH 2
THT 1
TTH 1
TTT 0

Fall 2023
Ch 02: 17
Discrete random variable
Probability function
Assign a number for each out come, i.e. Get the values of X:

x f(x)=P(X=x)

0 P(TTT)= 1/27
P(HTT, THT, TTH)=
1
2/27+2/27+2/27 =6/27
2 P(HHT,THH,HTH) = 4/27+4/27+4/27= 12/27

3 P(HHH) = 8/27

This information is put in the form of a table as follows:

x 0 1 2 3
f(x) 1/27 6/27 12/27 8/27

Fall 2023
Ch 02: 18

Example
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.
Let X be a random variable whose values x are the possible numbers
of defective computers purchased by the school. Then x can only
take the numbers 0, 1, and 2.

Fall 2023
Discrete random variable Ch 02: 19

Cumulative distribution function

Definition:
Let X : S → R be a discrete random variable with
probability function f(x).

The cumulative distribution function for X, F(x), is


defined by

F(x) = P(X  x) =  f (t)


t x
for -  < x < 

Fall 2023
Ch 02: 20
Discrete random variable
Cumulative distribution function

Example: Flip three coins X : # heads X : S → {0,1,2,3}


Outcome Value of X Probability function Cumulative dist. Func.
TTT X=0 f(0) = P(X=0) = 1/8 F(0) = P(X < 0) = 1/8
HTT, TTH, THT X=1 f(1) = P(X=1) = 3/8 F(1) = P(X < 1) = 4/8
HHT, HTH, THH X=2 f(2) = P(X=2) = 3/8 F(2) = P(X < 2) = 7/8
HHH X=3 f(3) = P(X=3) = 1/8 F(3) = P(X < 3) = 1

Probability function: Cumulative distribution function:


f(x) F(x) 1.0
0.4 0.8
0.3 0.6
0.2 0.4
0.1 0.2

0 1 2 3 x 0 1 2 3 x

Fall 2023
Ch 02: 21
Continuous random variable

A continuous random variable X has probability 0 for all


outcomes!!

Mathematically: P(X = x) = f(x) = 0 for all x

Hence, we cannot represent the probability function f(x) by a


table or bar chart as in the case of discrete random variables.
Instead, we use a continuous function – a density function.

Fall 2023
Ch 02: 22
Continuous random variable
Density function
Definition:
Let X: S → R be a continuous random variables.

A probability density function f(x) for X is defined by:

1. f(x)  0 for all x



2.  f ( x ) dx = 1
−
b
3. P( a < X < b ) =  f(x) dx
a

Note!! Continuity: P(a < X < b) = P(a < X < b) = P(a < X < b) = P(a < X < b)

Fall 2023
Ch 02: 23
Continuous random variable
Density function
Example: X: service life of car battery in years (contiuous)
Density function: 0.5

− 0.16 + 0.16x for 1  x  3.5


0.4


0.3

f ( x) =  0.96 − 0.16x for 3.5  x  6 0.2


0.1

 0 otherwise 0
1 3.5 6
3

What is probability of a service life longer than 3 years?



P ( X  3) =  f ( x) dx
3
3 .5 6
=  (−0.16 + 0.16 x) dx +  (0.96 − 0.16 x) dx
3 3 .5

=  = 0.68

Fall 2023
Ch 02: 24
Continuous random variable
Density function
Alternative solution:
0,5

− 0.16 + 0.16x for 1  x  3.5 0,4

 0,3
f ( x) =  0.96 − 0.16x for 3.5  x  6 0,2


 0 othwerwise 0,1

0
1 3 3,5 6

Probability of a service life longer than 3 years:


P ( X  3) = 1 − P ( X  3)
3
= 1−  f ( x) dx
−
3
= 1 −  (−0.16 + 0.16 x) dx
1

=  = 1 − 0.32 = 0.68

Fall 2023
Ch 02: 25
Continuous random variable
Density function
Example: Suppose that the error in the reaction temperature, in oC,
for a controlled laboratory experiment is a continuous random variable X
having the probability density function

(a) Verify that f(x) is a density function.


(b) Find P(0 < X ≤ 1).

Fall 2023
Ch 02: 26
Continuous random variable
Density function
Solution:
(a) Obviously, f(x) ≥ 0. To verify condition 2 in Definition, we have

(b) Using formula 3 in Definition, we obtain

Fall 2023
Ch 02: 27
Continuous random variable
Density function
Definition:
Let X : S → R be a contiguous random variable with density
function f(x).

The cumulative distribution function for X, F(x), defined by


x
F(x) = P(X  x) =  f ( t ) dt
−
for -  < x < 
Note: F(x) = f(x)
F(3) = P( X  3) 0,5

3 0,4

=  f ( x ) dx 0,3

− 0,2

3 0,1

=  − 0.16 + 0.16x dx 0
1 3 3,5 6
1

=  = 0.32

Fall 2023
Ch 02: 28
Continuous random variable
Density function
From the definition of the cumulative distribution funct. we get:

P( a < X < b ) = P( a < X < b ) = P( a < X < b ) = P( a < X < b )


= P(X < b ) – P(X < a )
= F(b) – F(a)

0,5

0,4

0,3

0,2

0,1

0
1 a 3,5 b 6

Fall 2023
Ch 02: 29
Continuous random variable
Density function
Example: For the density function of the previous Example, find F(x),
and use it to evaluate P(0 < X ≤ 1).

Solution:
For −1 < x < 2,

Therefore,

Fall 2023
Ch 02: 30
Continuous random variable
Density function
The cumulative distribution function F(x) is expressed in the Figure
shown.

Now P(0 < X ≤ 1) = F(1) − F(0) = 2/9 − 1/9 = 1/9,

Fall 2023
Continuous random variable Ch 02: 31

Example:
The Department of Energy (DOE) puts projects out on bid and
generally estimates what a reasonable bid should be. Call the
estimate b. The DOE has determined that the density function of
the winning (low) bid is

Find F(y) and use it to determine the probability that the winning
bid is less than the DOE’s preliminary estimate b.

Fall 2023
Ch 02: 32

To determine the probability that the winning bid is less than the
preliminary bid estimate b, we have

Fall 2023
Ch 02: 33

Discrete random variable Continuous random variable

• Sample space is finite or has • The sample space contains


countable many outcomes infinitely many outcomes

• Probability function f(x) • Density function f(x) is a


Is often given by table Continuous function

• Calculation of probabilities • Calculation of probabilities


b

P( a < X < b) =  f(t) P( a < X < b ) =  f(t) dt


a<t<b a

Fall 2023
Ch 02: 34
Joint distribution
Joint probability function
it desirable to record the simultaneous outcomes of several random
variables. For example:
• In wireless communication systems, the joint distribution of
received signal strength and noise power may be studied to
analyze system performance and optimize receiver design.

• In civil, when studying the strength of a bridge, engineers may


consider the joint distribution of factors such as material
properties and loading conditions

• In renewable energy systems such as a solar photovoltaic system,


engineers may analyze the joint distribution of panel orientation,
shading effects, and temperature to optimize system performance
and maximize energy output.
Fall 2023
Ch 02: 35
Joint distribution
Joint probability function (discrete)

Definition:
Let X and Y be two discrete random variables.
The joint probability function f(x,y) for X and Y
Is defined by
1. f(x,y)  0 for all x and y

2.   f ( x, y ) = 1
x y

3. P(X = x ,Y = y) = f(x,y) (the probability that both X = x and Y=y)

For a set A in the xy plane: P(( X, Y )  A ) =   f ( x, y )


( x ,y ) A

Fall 2023
Example of Joint probability distribution Ch 02: 36

Example:
Let's say we have a function f(X, Y) that represents the probability
of a smartphone needing Y replacement components after being
used for X hours. So, if X represents the number of hours the
smartphone has been used and Y represents the number of
components that need replacement, then f(2000, 2) could
represent the probability that a smartphone used for 2000 hours
requires 2 replacement components.

Fall 2023
Ch 02: 37
Joint distribution
Joint probability function
Example:
Two ballpoint pens are selected at random from a box that contains 3 blue
pens, 2 red pens, and 3 green pens. If X is the number of blue pens selected
and Y is the number of red pens selected, find
(a) the joint probability function f(x, y),
(b) P[(X, Y) ∈ A], where A is the region {(x, y)| x + y ≤ 1}.

Solution

Fall 2023
Ch 02: 38
Joint distribution
Joint probability function

The possible pairs of values (x, y) are (0, 0), (0, 1), (1, 0), (1, 1), (0, 2), and (2, 0).

(b) The probability that (X, Y) fall in the region A is

Fall 2023
Ch 02: 39
Joint distribution
Joint density function (continuous)

Definition 3.9:
Let X and Y be two continuous random variables.
The joint density function f(x,y) for X and Y is
defined by
1. f(x,y)  0 for all (x,y)
 
2. − − f ( x, y ) dx dy = 1
3. P(a < X< b, c<Y< d) = c  f ( x, y) dx dy
d b

For a region A in the xy-plane: P[(X,Y)A] =   f(x,y) dxdy


A

Fall 2023
Joint distribution Ch 02: 40

Example:

Fall 2023
Ch 02: 41

Fall 2023
Ch 02: 42
Joint distribution
Marginal probability function

Definition:
Let X and Y be two discrete random variables with joint
probability function f(x,y).
The marginal probability function for X is given by
g(x) = y f(x,y) for all x

The marginal probability function for Y is given by


h(y) =  f(x,y) for all y
x

Fall 2023
Ch 02: 43
Joint distribution
Marginal probability function
Example:
The joint probability function f(x,y) for X and Y where X
is the number of blue pens selected and Y is the number of
red pens selected is given by
h(y)
a) Probability of one red pen is
selected
P(Y =1)=h(1)= 3/14+3/14+0 = 3/7

b) Probability of two blue pens are g(x)


selected
• P(X= 2) =g(2) 3/28+0+0 = 3/28

• P(X+Y < 2) = 3/28+9/28+3/14 =


18/28 = 9/14

Fall 2023
Ch 02: 44
Joint distribution
Marginal density function

Definition:
Let X and Y be two continuous random variables with
joint density function f(x,y).
The marginal
density function for X is given by
g ( x) =  f ( x, y) dy
−
for all x
The marginal density function for Y is given by

h( y ) =  f ( x, y) dx
−
for all y

Fall 2023
Ch 02: 45
Joint distribution
Marginal density function
Example
Joint density f(x,y) for X and Y: 2

2
1.5

 (2x + 3y) 0  x  1, 0  y  1
f(x, y) =  5 1


1

 0 otherwise 0.5

0 0.5

Find g(x) and h(y) for the joint density function 1


0.8
0.6
0.4
0.2 0
0

Fall 2023
Ch 02: 46
Joint distribution
Conditional density and probability functions

Definition:
Let X and Y be random variables (continuous or discrete)
with joint density/probability function f(x,y). Then the
Conditional density/probability function for Y given X=x is

where g(x) is the marginal density/probability function for X, and


the conditional density/probability function for X given Y=y is

where h(y) is the marginal density/probability function for Y.

Fall 2023
Ch 02: 47
Joint distribution
Conditional probability function
Example:
Joint probability function
f(x,y) for X and Y is given by:

h(y)
• P(Y=1 | X=1 ) = f(1|1)
= f(1,1) / g(1)
= (3/14) / (15/28)
= 6/15
g(x)
• P(Y>=1 | X=0 ) =
3 1
+ 7
14 28
= 10 =
10
28

Fall 2023
Ch 02: 48
Joint distribution
Conditional probability function
Examples:
The joint density for the random variables (X, Y ), where X is the unit
temperature change and Y is the proportion of spectrum shift that a certain
atomic particle produces, is

(a) Find the marginal densities g(x), h(y), and the conditional density f(y|x).
(b) Find the probability that the spectrum shifts more than half of the total
observations, given that the temperature is increased by 0.25 unit.

Fall 2023
Ch 02: 49
Joint distribution
Conditional probability function
Examples:
The joint density for the random variables (X, Y ), where X is the unit
temperature change and Y is the proportion of spectrum shift that a certain
atomic particle produces, is

(a) Find the marginal densities g(x), h(y), and the conditional density f(y|x).
(b) Find the probability that the spectrum shifts more than half of the total
observations, given that the temperature is increased by 0.25 unit.

Fall 2023
Ch 02: 50
Joint distribution
Conditional probability function
Examples:
The joint density for the random variables (X, Y ), where X is the unit
temperature change and Y is the proportion of spectrum shift that a certain
atomic particle produces, is

(a) Find the marginal densities g(x), h(y), and the conditional density f(y|x).
(b) Find the probability that the spectrum shifts more than half of the total
observations, given that the temperature is increased by 0.25 unit.

Fall 2023
Ch 02: 51

Example

Solution

Fall 2023
Ch 02: 52

Fall 2023
Ch 02: 53
Joint distribution
Independence

Definition:
Two random variables X and Y (continuous or discrete) with
joint density/probability functions f(x,y) and marginal
density/probability functions g(x) and h(y), respectively, are
said to be independent if and only if
f(x,y) = g(x) h(y) for all x,y

or if f(x|y) = g(x) (x indep. of y) or f(y|x)=h(y) (y indep. of x)

Fall 2023
Ch 02: 54

Example

Solution:
Since X1, X2, and X3 are independent

Fall 2023

You might also like