Probability First 4 Lec
Probability First 4 Lec
Department of Mathematics
Al-Azhar University, Cairo, Egypt
1
Q: Why we study statistics?
Statistics is the science of making sense of data and
of how to gather data.
2
Key Components of statistics
Population and Sample Analysis
Descriptive
Quantitative Variable(s)
Inferences
Categorical Variable(s)
Estimation
Population(s)
Hypotheses Testing
Sample(s)
Parametric Methods
Distributions
Non-Parametric Methods
Population Mean
Sample mean Statistical Models
Population variance
Sample Variance Regression
Population standard deviation
Sample standard Deviation Time series
…..? …..?
3
4
5
Some Basic Concepts
Sets
6
Probability
An Experiment: is some procedure (or process) that we do and
it results in an outcome.
7
2 Events:
Definition 2:
An event A is a subset of the sample space S. That is A S.
· We say that an event A occurs if the outcome (the result)
of the experiment is an element of A.
· S is an event ( is called the impossible event)
· SS is an event (S is called the sure event)
Example:
Experiment: Selecting a ball from a box containing 6 balls
numbered 1,2,3,4,5 and 6. (or tossing a die)
8
This experiment has 6 possible outcomes
The sample space is S={1,2,3,4,5,6}.
Consider the following events:
E1= getting an even number ={2,4,6}S
E2 = getting a number less than 4={1,2,3}S
E3 = getting 1 or 3={1,3}S
E4 = getting an odd number={1,3,5}S
E5 = getting a negative number={ }= S
E6 = getting a number less than 10 = {1,2,3,4,5,6}=S S
Notation:
•n(S)= no. of outcomes (elements) in S.
•n(E)= no. of outcomes (elements) in the event E.
Example:
Experiment: Selecting 3 items from manufacturing process;
each item is inspected and classified as defective (D) or non-
defective
9 (N).
This experiment has 8 possible outcomes
S={DDD,DDN,DND,DNN,NDD,NDN,NND,NNN}
10
· Consider the following events:
A={at least 2 defectives}= {DDD,DDN,DND,NDD}S
B={at most one defective}={DNN,NDN,NND,NNN}S
C={3 defectives}={DDD}S
11
Some Operations on Events:
Let A and B be two events defined on the sample space S.
Definition 2.3: Complement of The Event A:
· Ac or A' S
· Ac = {x S: xA }
· Ac consists of all points of S that are not
in A.
· Ac occurs if A does not.
12
Probability and Statistics
Prof. Khalaf S. Sultan
Department of Mathematics
Al-Azhar University, Cairo, Egypt
Probability #02
1
Some Operations on Events:
Let A and B be two events defined on the sample space S.
Definition: Complement of The Event A:
· Ac or A' S
· Ac = {x S : xA }
· Ac consists of all points of S that are not
in A.
· Ac occurs if A does not.
Definition: Intersection: S
2
Definition: Mutually Exclusive (Disjoint) Events:
AB AB =
A and B are not A and B are
mutually mutually
exclusive exclusive
(disjoint)
3
Definition: Union:
• AB = {x S: xA or xB } S
4
Combinations: (order is not important)
In many problems, we are interested in the number of ways of
selecting r objects from n objects without regard to order. These
selections are called combinations.
· Notation:
n factorial is denoted by n! and is defined by:
n!= n (n − 1) (n − 2 ) (2 ) (1) for n = 1, 2,
0!= 1
Example: 5!= 5 4 3 2 1 = 120
Theorem:
The number of combinations of n distinct objects taken r at a
time is denoted by n and is given by:
r
n n!
= ; r = 0, 1, 2, , n
r r ! (n − r )!
5
Notes:
n
· is read as “ n “ choose “ r ”.
r
n n n n n
· = 1 , = 1 , = n , =
n 0 1 r n − r
· n = The number of different ways of selecting r objects
r
from n distinct objects.
n
· = The number of different ways of dividing n distinct
r
objects into two subsets; one subset contains r
objects and the other contains the rest (n −r) objects.
6
Example:
If we have 10 equal–priority operations and only 4 operating
rooms are available, in how many ways can we choose the 4
patients to be operated on first?
Solution:
n = 10 r = 4
The number of different ways for selecting 4 patients from 10
patients is
7
Theorem: Permutations (order is important)
8
Probability of an Event:
HH P(HH) = w
HT P(HT) = w 4w =1 w =1/4 = 0.25
TH P(TH) = w P(HH)=P(HT)=P(TH)=P(TT)=0.25
TT P(TT) = w
sum 4w=1
10
The probability that at least one head occurs is:
P(A) = P({at least one head occurs})=P({HH, HT, TH})
= P(HH) + P(HT) + P(TH)
= 0.25+0.25+0.25
= 0.75
Theorem:
If an experiment has n(S)=N equally likely different outcomes,
then the probability of the event A is:
n( A) n( A) no. of outcomes in A
P( A) = = =
n( S ) N no. of outcomes in S
11
Example:
A mixture of candies consists of 6 mints, 4 toffees, and 3
chocolates. If a person makes a random selection of one of
these candies, find the probability of getting:
(a) a mint
(b) a toffee or chocolate.
Solution:
Define the following events:
M = {getting a mint}
T = {getting a toffee}
C = {getting a chocolate}
Experiment: selecting a candy at random from 13 candies
n(S) = no. of outcomes of the experiment of selecting a candy.
= no. of different ways of selecting a candy from 13 candies.
13
= = 13
1 12
The outcomes of the experiment are equally likely because
the selection is made at random.
(a) M = {getting a mint}
n(M) = no. of different ways of selecting a mint candy
from 6 mint candies
6
= = 6
1 n(M ) 6
P(M )= P({getting a mint})= =
n(S ) 13
(b) TC = {getting a toffee or chocolate}
n(TC) = no. of different ways of selecting a toffee
or a chocolate candy
= no. of different ways of selecting a toffee
candy + no. of different ways of selecting a
chocolate candy
4 3
= + = 4 + 3 = 7
1 1
13
= no. of different ways of selecting a candy
from 7 candies
7
= = 7
1 n(T C ) 7
P(TC )= P({getting a toffee or chocolate})= =
n(S ) 13
14
Additive Rules:
Theorem 1:
If A and B are any two events, then:
P(AB)= P(A) + P(B) − P(AB)
Proof:
?
15
Corollary 1:
If A and B are mutually exclusive (disjoint) events, then:
P(AB)= P(A) + P(B)
Corollary 2:
If A1, A2, …, An are n mutually exclusive (disjoint) events, then:
P(A1 A2 … A n)= P(A1) + P(A2) +… + P(An)
n n
P Ai = P ( Ai )
i =1 i =1
16
17
18
Theorem 3
Proof:
19
Note: Two event Problems:
Total area= P(S)=1.
In Venn diagrams, consider
the probability of an event A as
the area of the region
corresponding to the event A.
* Total area= P(S)=1
20
Example:
The probability that Mohamed passes Mathematics is 2/3, and
the probability that he passes English is 4/9. If the probability
that he passes both courses is 1/4,
what is the probability that he will:
(a) pass at least one course?
(b) pass Mathematics and fail English?
(c) fail both courses?
Solution:
Define the events:
M={Mohamed passes Mathematics}
E={Mohamed passes English}
We know that P(M)=2/3, P(E)=4/9, and P(ME)=1/4.
(a) Probability of passing at least one course is:
P(ME)= P(M) + P(E) − P(ME)
21
(a) Probability of passing at least one course is:
P(ME)= P(M) + P(E) − P(ME)
2 4 1 31
= + − =
3 9 4 36
22
Example
The probability that Mohamed passes Mathematics is 2/3, and
the probability that he passes English is 4/9. If the probability
that he passes both courses is 1/4, what is the probability that
he will:
(a) pass at least one course?
(b) pass Mathematics and fail English?
(c) fail both courses?
Solution:
Define the events: M={Mohamed passes Mathematics}
E={Mohamed passes English}
We know that P(M)=2/3, P(E)=4/9, and P(ME)=1/4.
(a) Probability of passing at least one course is:
P(ME)= P(M) + P(E) − P(ME)
2 4 1 31
= + − =
3 9 4 36
23
(b) Probability of passing Mathematics and failing English is:
P(MEC)= P(M) − P(ME)
2 1 5
= − =
3 4 12
(c) Probability of failing both courses is:
P(MCEC)= 1 − P(ME)
31 5
= 1− =
36 36
Theorem 2.12:
If A and AC are complementary events, then:
P(A) + P(AC) = 1 P(AC) = 1 − P(A)
Conditional Probability:
The probability of occurring an event A when it is known that
some event B has occurred is called the conditional
probability of A given B and is denoted P(A|B).
24
Definition
The conditional probability of the
event A given the event B is defined by:
P( A B )
P( A | B ) = ; P(B ) 0
P(B )
Notes:
P( A B )
1. P( A | B ) = = P(S)=Total area=1
P (B )
n ( A B ) / n (S ) n ( A B )
= = ; for equally likely outcomes case
n ( B ) / n (S ) n( B )
P( A B )
2. P(B | A) =
P ( A)
3. P( A B ) = P( A) P(B | A)
(Multiplicative Rule)
= P(B ) P( A | B )
25
Example:
339 physicians are classified as given in the table below. A
physician is to be selected at random.
26
Smoking Habit
Daily Occasionally Not at all
(B1) (B2) (B3) Total
Age 20 - 29 (A1) 31 9 7 47
40 - 49 (A3) 29 21 29 79
50+ (A4) 6 0 18 24
27
Solution:
n(S) = 339 equally likely outcomes.
Define the following events:
A3 = the selected physician is aged 40 – 49
B2 = the selected physician smokes occasionally
A3 B2 = the selected physician is aged 40 – 49 and smokes
occasionally
(1) (a) A3 = the selected physician is aged 40 – 49
n( A3 ) 79
P( A3 ) = = = 0.2330
n(S ) 339
(b) B2 = the selected physician smokes occasionally
n(B2 ) 60
P(B2 ) = = = 0.1770
n(S ) 339
(c) A3 B2 = the selected physician is aged 40 – 49 and
smokes occasionally.
n( A3 B2 ) 21
P( A3 B2 ) = = = 0.06195
n(S ) 339 28
(2) A3|B2 = the selected physician is aged 40 – 49 given that the
physician smokes occasionally
n (A 3 B2 ) 21
(i)P(A 3 | B2 ) = = = 0.35
n (B2 ) 60
P(A 3 B2 ) 0.06195
(ii)P(A 3 | B2 ) = = = 0.35
P(B2 ) 0.1770
21
(iii) We can use the restricted table directly: P( A3 | B2 ) = = 0.35
60
Notice that P(A3|B2)=0.35 > P(A3)=0.233.
The conditional probability does not equal unconditional
probability; i.e., P(A3|B2) P(A3) ! What does this mean?
29
Note:
· P(A|B) = P(A) means that knowing B has no effect on the
probability of occurrence of A. In this case A is independent of B.
· P(A|B) > P(A) means that knowing B increases the probability
of occurrence of A.
· P(A|B) < P(A) means that knowing B decreases the probability
of occurrence of A.
Independent Events:
Definition
Two events A and B are independent if and only if P(A|B)=P(A)
and P(B|A)=P(B). Otherwise A and B are dependent.
Example:
In the previous example, we found that P(A3|B2) P(A3).
Therefore, the events A3 and B2 are dependent, i.e., they are
not independent. Also, we can verify that P(B2| A3) P(B2).
30
Multiplicative Rule:
Theorem
If P(A) 0 and P(B) 0, then:
P(AB) = P(A) P(B|A)
= P(B) P(A|B)
Example
Suppose we have a fuse box containing 20 fuses of which 5 are
defective (D) and 15 are non-defective (N). If 2 fuses are
selected at random and removed from the box in succession
without replacing the first, what is the probability that both fuses
are defective?
Solution:
Define the following events:
A = {the first fuse is defective}
B = {the second fuse is defective}
AB={the first fuse is defective and the second fuse is
defective} = {both fuses are defective} 31
We need to calculate P(AB).
5
P(A) = 20
4
P(B|A) =
19
P(AB) = P(A) P(B|A)
5 4
= = 0.052632
20 19
32
Theorem
Two events A and B are independent if and only if
P(AB)= P(A) P(B)
*(Multiplicative Rule for independent events)
Note:
Two events A and B are independent if one of the following
conditions is satisfied:
(i) P(A|B)=P(A)
(ii) P(B|A)=P(B)
(iii) P(AB)= P(A) P(B)
Theorem 2.15: (k=3)
· If A1, A2, A3 are 3 events, then:
P(A1 A2 A3)= P(A1) P(A2| A1) P(A3| A1 A2)
· If A1, A2, A3 are 3 independent events, then:
P(A1 A2 A3)= P(A1) P(A2) P(A3)
33
Example cards are drawn in succession, without replacement,
from an ordinary deck of playing cards. Fined P(A1 A2 A3),
where the events A1, A2 , and A3 are defined as follows:
A1 = {the 1-st card is a red ace}
A2 = {the 2-nd card is a 10 or a jack}
A3 = {the 3-rd card is a number greater than 3 but less than 7}
Solution:
P(A1) = 2/52
P(A2 |A1) = 8/51
P(A3| A1 A2) = 12/50
P(A1 A2 A3)
= P(A1) P(A2| A1) P(A3| A1 A2)
2 8 12 192
= = = 0.0014479
52 51 50 132600
34
Example
Suppose we have a fuse box containing 20 fuses of
which 5 are defective (D) and 15 are non-defective (N). If
3fuses are selected at random and removed from the
box in succession without replacing the first, what is the
probability that the all three fuses are defective?
Solution:
• Define the following events:
• A1 = {the first fuse is defective}
• A2= {the second fuse is defective}
• A3= {the third fuse is defective}
• A1A2 A3 = {The all three fuses are defective}
35
We need to calculate P(A1A2 A3).
P(A1) = 5/20
P(A2|A1) =4/19
=(5/20)(4/19)(3/18)=0.0088
36
Probability and Statistics
Prof. Khalaf S. Sultan
Department of Mathematics
Al-Azhar University, Cairo, Egypt
Probability #02
1
Bayes' Rule:
Definition:
The events A1, A2,…, and An constitute a partition of the sample
space S if:
n
❖ A
i =1
i = A1 A 2 ... A n = S
❖ Ai Aj = , i j
Theorem : (Total Probability)
If the events A1, A2,…, and An constitute
a partition of the sample space S
such that P(Ak)0 for k=1, 2, …, n,
then for any event B:
n
P(B) = P(Ak ) P(B | A k )
k =1
n
= P(Ak B)
k =1 2
Example:
Three machines A1, A2, and A3 make 20%, 30%, and 50%,
respectively, of the products. It is known that 1%, 4%, and 7% of
the products made by each machine, respectively, are
defective. If a finished product is randomly selected, what is the
probability that it is defective?
3
Solution:
Define the following events:
B = {the selected product is defective}
A1 = {the selected product is made by machine A1}
A2 = {the selected product is made by machine A2}
A3 = {the selected product is made by machine A3}
20 1
P(A1) = = 0.2; P(B | A1) = = 0.01
100 100
30 4
P(A2) = = 0.3; P(B | A2) = = 0.04
100 100
50 7
P(A3) = = 0.5; P(B | A3) = = 0.07
100 100
3
P(B) = P(Ak ) P(B | A k )
k =1
= P(A1) P(B|A1) + P(A2) P(B|A2) + P(A3) P(B|A3)
= 0.20.01 + 0.30.04 + 0.50.07
= 0.002 + 0.012 + 0.035
= 0.049 4
Question:
If it is known that the selected product is defective, what is the
probability that it is made by machine A1?
Answer:
P(A1 B) 0.2 0.01 0.002
P(A1 | B) = = = = 0.0408
P(B) 0.049 0.049
This rule is called Bayes' rule.
5
Theorem : (Bayes' rule)
If the events A1,A2,…, and An constitute a partition of the sample
space S such that P(Ak)0 for k=1, 2, …, n, then for any event B
such that P(B)0:
P(Ai B) P(Ai ) P(B | Ai ) P(Ai ) P(B | Ai )
P(Ai | B) = = n
=
P(A ) P(B | A
P(B) P(B)
k k )
k =1
for i = 1, 2, …, n.
6
Example
In Example 2.38, if it is known that the selected product is
defective, what is the probability that it is made by:
(a) machine A2?
(b) machine A3?
Solution:
P(A2 ) P(B | A 2 ) P(A2 ) P(B | A 2 )
(a )P(A 2 | B) = n
=
P(A ) P(B | A
P(B)
k k )
k =1
7
P(A3 ) P(B | A3 ) P(A3 ) P(B | A 3 )
(b)P(A 3 | B) = n
=
P(A ) P(B | A
P(B)
k k )
k =1
0.5 0.07 0.035
= = = 0.7142
0.049 0.049
8
Note:
P(A1|B) = 0.0408, P(A2|B) = 0.2449, P(A3|B) = 0.7142
3
▪ P(Ak | B) = 1
k =1
▪ If the selected product was found defective, we should
check machine A3 first, if it is ok, we should check machine
A2, if it is ok, we should check machine A1.
9
Application
An electrical system consists of four components as
illustrated in the Figure
10
11
Find the probability that
Solution
12
P [A B (C D )] = P (A )P (B )P (C D )
= P (A )P (B )[P (C ) + P (D ) − P (C )P (D )]
= (0.9)(0.9)[0.8 + 0.8 − (0.8)(0.8)]
= 0.7776
13
(b) The probability that the component
C does not work, given that the entire system works.
14
Lecture #4
Random Variables and Probability Distributions
Example:
· Experiment: testing two components. (D=defective, N=non-
defective)
· Sample space: S={DD,DN,ND,NN}
· Let X = number of defective components when two
components are tested.
· Assigned numerical values to the outcomes are:
1
Sample point Assigned
(Outcome) Numerical Value (x)
DD 2
DN 1
ND 1
NN 0
3
4.2 Discrete Probability Distributions
· A discrete random variable X assumes each of its values
with a certain probability.
Example:
· Experiment: tossing a non-balance coin 2 times
independently.
· H= head , T=tail
· Sample space: S = {HH, HT, TH, TT}
· Suppose P(H)=½P(T) P(H)=1/3 and P(T)=2/3
· Let X= number of heads
Sample point Probability Value of X
(Outcome) (x)
HH P(HH)=P(H) P(H)=1/31/3 = 1/9 2
HT P(HT)=P(H) P(T)=1/32/3 = 2/9 1
TH P(TH)=P(T) P(H)=2/31/3 = 2/9 1
4
TT P(TT)=P(T) P(T)=2/32/3 = 4/9 0
· The possible values of X are: 0, 1, and 2.
· X is a discrete random variable.
· Define the following events:
Event (X=x) Probability = P(X=x)
(X=0)={TT} P(X=0) = P(TT)=4/9
(X=1)={HT,TH} P(X=1) =P(HT)+P(TH)=2/9+2/9=4/9
(X=2)={HH} P(X=2) = P(HH)= 1/9
X 0 1 2 Total
2
f(x)= P(X=x) 4/9 4/9 1/9 f ( x) = 1
x =0
6
P(X<1) = P(X=0)=4/9
P(X1) = P(X=0) + P(X=1) = 4/9+4/9 = 8/9
P(X0.5) = P(X=1) + P(X=2) = 4/9+1/9 = 5/9
P(X>8) = P() = 0
P(X<10) = P(X=0) + P(X=1) + P(X=2) = P(S) = 1
Example
A shipment of 8 similar computers
to a retail outlet contains 3 that are
defective and 5 are non-defective.
If a school makes a random purchase of 2
of these computers, find the probability
distribution of the number of defectives.
Solution:
We need to find the probability distribution of the random
variable: X = the number of defective computers purchased.
Experiment: selecting 2 computers at random out of 8
8
n(S) = 2 equally likely outcomes 7
The possible values of X are: x=0, 1, 2.
Consider the events:
3 5
(X = 0) = {0D and 2N} n(X = 0) =
0 2
3 5
(X = 1) = {1D and 1N} n(X = 1) =
1 1
3 5
(X = 2) = {2D and 0N} n(X = 2) =
2 0
3 5
n (X = 0) 0 2 10
f ( 0) = P ( X = 0) = = =
n (S) 8 28
2
8
3 5
n (X = 1) 1 1 15
f (1) = P(X = 1) = = =
n (S) 8 28
2
3 5
n (X = 2) 2 0 3
f (2) = P(X = 2) = = =
n (S) 8 28
2
In general, for x=0,1, 2, we have:
3 5
n (X = x ) x 2 − x
f ( x ) = P(X = x ) = =
n (S) 8
2
9
The probability distribution of X is:
x 0 1 2 Total
10 15 3
f(x)= P(X=x) 1.00
28 28 28
3 5
x 2 − x ; x = 0, 1, 2
f ( x) = P( X = x) = 8 Hypergeometric
Distribution
2
0 ; otherwise
Definition
The cumulative distribution function (CDF), F(x), of a discrete
random variable X with the probability function f(x) is given by:
F(x) = P(X x ) = f ( t ) = P(X = t ); for −<x<
tx tx 10
Example:
Find the CDF of the random variable X with the probability
function:
X 0 1 2
10 15 3
f(x)
28 28 28
Solution:
F(x)=P(Xx) for −<x<
For x<0: F(x)=0
10
For 0x<1: F(x)=P(X=0)=
28
10 15 25
For 1x<2: F(x)=P(X=0)+P(X=1)= + =
28 28 28
10 15 3
For x2: F(x)=P(X=0)+P(X=1)+P(X=2)= + + =1
28 28 28
11
The CDF of the random variable X is:
0 ; x0
10
; 0 x 1
28
F ( x) = P( X x) =
25 ; 1 x 2
28
1 ; x2
Note:
F(−0.5) = P(X−0.5)=0
25
F(1.5)=P(X1.5)=F(1) =
28
F(3.8) =P(X3.8)=F(2)= 1
Result:
P(a < X b) = P(X b) − P(X a) = F(b) − F(a)
P(a X b) = P(a < X b) + P(X=a) = F(b) − F(a) + f(a)
P(a < X < b) = P(a < X b) − P(X=b) = F(b) − F(a) − f(b) 12
Result:
Suppose that the probability function of X is:
x x1 x2 x3 … xn
4. P(XA) = f(x) dx
A
15
area = P(a X b )
1 = xd ) x( f
− =aera latoT = a f ( x ) dx
b
area = P( X b ) area = P( X a )
= b f ( x ) dx = − f ( x ) dx
a
16
Example
Suppose that the error in the reaction temperature, in oC, f
controlled laboratory experiment is a continuous rand
variable X having the following probability density function:
1 2
x ; −1 x 2
f ( x) = 3
0 ; elsewhere
1. Verify that (a) f(x) 0 and (b) f(x) dx = 1
2. Find P(0<X1) -
Solution:
X = the error in the reaction
temperature in oC.
X is continuous r. v.
1 2
x ; −1 x 2
f ( x) = 3
0 ; elsewhere
17
1. (a) f(x) 0 because f(x) is a quadratic function.
−1 2
1 2
(b) - f(x) dx = - 0 dx + -1 3 x dx + 2 0 dx
2
1 2 1 3 x = 2
= x dx = x
-1
3 9 x = −1
1
= (8 − (−1)) = 1
9
1 11
2. P(0<X1) = f(x) dx = x dx
2
0 03
1 3 x = 1
= x
9 x = 0
1
= (1 − (0))
9
1
=
9
18
Definition
The cumulative distribution function (CDF), F(x), of a continuous
random variable X with probability density function f(x) is given
by: x
Result:
P(a < X b) = P(X b) − P(X a) = F(b) − F(a)
Example:
in Example 3.6,
1.Find the CDF
2.Using the CDF, find P(0<X1).
19
Solution:
1 2
x ; −1 x 2
f ( x) = 3
0 ; elsewhere
20
For x2:
x −1 2 x
1 2 2
F(x) = f(t) dt = 0 dt + t dt + 0 dt = t 2 dt = 1
1
- - -1
3 2 3
-1
Therefore, the CDF is:
0 ; x −1
1
F ( x) = P( X x) = ( x 3 + 1) ; − 1 x 2
9
1 ; x 2