PART I — PROBABILITY
1. What Is Probability?
Probability is a numerical measure of how likely an event is to occur.
The probability of an event A is denoted by
P(A)
and its value is always between 0 and 1:
0≤P(A)≤1
Interpretation:
Probability Interpretation
0 Impossible
Between 0 and 1 Possible
1 Certain
0.5 Equally likely to occur or not occur
Probability is extremely important in computer engineering because many
engineering processes involve uncertainty.
Examples include:
probability of a communication error;
probability that a server fails;
probability that a sensor detects an object;
probability of a defective electronic component;
probability of a packet being lost;
probability that a particular bit is transmitted incorrectly.
Example 1: Probability of Getting a Head
A fair coin is tossed once. What is the probability of obtaining a head?
Step 1: Identify possible outcomes
S={H,T}
There are 2 possible outcomes.
Step 2: Identify the favorable outcome
The favorable outcome is:
H
There is 1 favorable outcome.
Step 3: Apply the probability formula
P(H)= Number of favorable outcomes / Total number of outcomes
Therefore,
P(H)= 1/2
Answer:
P(H)=0.5
or 50%.
Example 2: Rolling a Die
A fair six-sided die is rolled once. What is the probability of obtaining a number
greater than 4?
Step 1: Sample space
S={1,2,3,4,5,6}
Step 2: Favorable outcomes
Numbers greater than 4 are:
{5,6}
There are 2 favorable outcomes.
Step 3: Calculate
P(A)= 2/6 P(A)= 1/3
Answer:
P(A)= 1/3 ≈0.3333
Thus, there is approximately a 33.33% chance.
Example 3: Defective Computer Components
Suppose a batch contains 100 processors, and 4 are defective. If one processor is
selected randomly, what is the probability that it is defective?
Step 1: Total components
100
Step 2: Defective components
Step 3: Probability
P(D)= 4/100 P(D)= 0.04
Answer:
P(D)= 0.04 = 4%
Example 4: Bit Transmission
Suppose a communication system transmits one bit. The probability that the bit is
transmitted incorrectly is 0.02.
What is the probability that the bit is transmitted correctly?
Step 1: Define the events
Let
E=bit is transmitted incorrectly
Given:
P(E)= 0.02
Step 2: Use the complement
The event "correctly transmitted" is the complement of an error.
Therefore,
P(Ec)=1−P(E)
Step 3: Calculate
P(Ec)=1−0.02 P(Ec)=0.98
Answer:
0.98
There is a 98% probability that the bit is transmitted correctly.
Example 5: Sensor Detection
A motion sensor correctly detects a person 95% of the time. What is the probability
that it fails to detect the person?
Step 1:
P(correct detection)=0.95
Step 2: Use the complement rule
P(failure)= 1−P(correct detection)
Step 3:
P(failure)= 1−0.95
P(failure)= 0.05
Answer:
P(failure)= 0.05 = 5%
PART II — SAMPLE SPACE AND RELATIONSHIPS AMONG EVENTS
2. Sample Space
The sample space is the set of all possible outcomes of a random experiment.
It is usually represented by:
Examples
For tossing a coin:
S={H,T}
For rolling a die:
S={1,2,3,4,5,6}
For tossing two coins:
S={HH,HT,TH,TT}
3. Events
An event is a subset of the sample space.
For example, when rolling a die:
S={1,2,3,4,5,6}
Let A be the event of obtaining an even number:
A={2,4,6}
Thus,
A⊆S
4. Relationships Among Events
Important relationships include:
1. Complementary events
2. Mutually exclusive events
3. Overlapping events
4. Independent events
5. Dependent events
6. Union
7. Intersection
4.1 Complementary Events
The complement of event A consists of all outcomes in S that are not in A.
It is represented by:
Ac
The fundamental relationship is:
P(Ac)=1−P(A)
Example 6: Complement of an Event
A die is rolled. Let
A={2,4,6}
Find Ac.
Step 1:
The sample space is
S={1,2,3,4,5,6}
Step 2:
Remove the elements of A:
A={2,4,6}
The remaining elements are:
Ac={1,3,5}
Answer:
Ac={1,3,5}
5. Mutually Exclusive Events
Two events are mutually exclusive if they cannot occur at the same time.
Mathematically:
A∩B=∅
For example, when rolling one die:
A={1,2}
B={5,6}
There is no common outcome.
Therefore:
A∩B=∅
Example 7: Mutually Exclusive Events
A die is rolled. What is the probability of obtaining either a 1 or a 6?
Step 1:
Let
A={1}
and
B={6}
They are mutually exclusive.
Step 2: Use the addition rule
For mutually exclusive events:
P(A∪B)=P(A)+P(B)
Step 3:
P(A)= 1/6 P(B)= 1/6
Therefore,
P(A∪B)= 1/6 + 1/6 = 2/6 = 1/3
Answer:
1/3
6. Overlapping Events
Two events are overlapping if they have one or more common outcomes.
For example, consider rolling a die.
Let:
A={2,4,6}
and
B={4,5,6}
The common outcomes are:
A∩B={4,6}
Therefore, they overlap.
7. Union of Events
The union of A and B contains all outcomes belonging to A, B, or both.
It is represented by:
A∪B
The general addition rule is:
P(A∪B)=P(A)+P(B)−P(A∩B)
The intersection is subtracted because it would otherwise be counted twice.
Example 8: Union of Two Events
A die is rolled.
Let
A = even number
and
B = number greater than 3
Find P(A∪B).
Step 1: Define the events
A={2,4,6} B={4,5,6}
Step 2: Find the intersection
A∩B={4,6}
Therefore:
P(A)=63 P(B)=63 P(A∩B)=62
Step 3: Apply the addition rule
P(A∪B)=P(A)+P(B)−P(A∩B) = 3/6 + 3/6 − 2/6 = 4/6
Answer:
P(A∪B)= 2/3
8. Independent Events
Events A and B are independent if the occurrence of one does not affect the
probability of the other.
For independent events:
P(A∩B)=P(A)P(B)
Example: Tossing a coin and rolling a die.
The coin result does not affect the die result.
Example 9: Independent Events
A coin is tossed and a die is rolled. Find the probability of getting a head and a 6.
Step 1:
P(H)= 1/2
Step 2:
P(6)= 1/6
Step 3: Multiply
Because the events are independent:
P(H∩6)= P(H) P(6) = 1/2 × 1/6 = 1/12
Answer:
1 / 12
9. Dependent Events
Events are dependent when the occurrence of one event affects the probability of
another.
A common example is drawing objects without replacement.
Example 10: Drawing Computer Components
A box contains 5 processors:
3 good processors
2 defective processors
Two processors are selected without replacement.
What is the probability that both are good?
Step 1: Probability first processor is good
P(G1)= 3/5
Step 2: After selecting one good processor
There are now:
2 good processors
4 total processors
Therefore:
P(G2∣G1)= 2/4 = 1/2
Step 3: Multiply
P(G1∩G2)= P(G1)P(G2∣G1) = 3/5 × 1/2 = 3/10
Answer:
0.30
There is a 30% probability that both selected processors are good.
PART III — COUNTING RULES USEFUL IN PROBABILITY
Counting techniques allow us to determine how many possible outcomes exist
without listing every outcome individually.
The major counting techniques are:
1. Fundamental counting principle
2. Factorial
3. Permutations
4. Combinations
10. Fundamental Counting Principle
If one task can be completed in m ways and another task can be completed in n ways,
then the two tasks can be completed in:
mn
ways.
Example 11: Computer Password
A password consists of:
2 letters
followed by 3 digits.
Assume repetition is allowed.
There are 26 choices for each letter and 10 choices for each digit.
Step 1:
First letter:
26
Step 2:
Second letter:
26
Step 3:
First digit:
10
Step 4:
Second digit:
10
Step 5:
Third digit:
10
Step 6: Multiply
26(26)(10)(10)(10) =676,000
Answer:
676,000 possible passwords.
11. Factorial
Factorial is represented by:
n!
and means:
n!= n(n−1)(n−2)⋯ (2)(1)
For example:
5!= 5(4)(3)(2)(1)=120
Also:
0!=1
Example 12: Factorial
Calculate:
7!
Solution:
7!=7(6)(5)(4)(3)(2)(1) = 5040
Answer:
5040
12. Permutations
A permutation is an arrangement where order matters.
The formula for arranging r objects selected from n objects is:
n Pr = n!/(n−r)!
Example 13: Arranging Engineers
Five students are competing for three positions:
President
Vice President
Secretary
In how many ways can the positions be assigned?
Step 1:
There are 5 candidates.
For President:
choices.
Step 2:
For Vice President:
choices remain.
Step 3:
For Secretary:
choices remain.
Step 4:
Multiply:
5(4)(3)=60
Using the permutation formula:
5P3 = 5! / (5−3)! = 5! / 2! = 120 / 2 = 60
Answer:
60
13. Combinations
A combination is a selection where order does not matter.
The formula is:
n Cr = n!/ r!(n−r)!
Example 14: Selecting Computer Engineering Students
There are 10 students. A group of 3 students must be selected for a research project.
How many different groups are possible?
Step 1:
Order does not matter.
Therefore, use combinations.
10C3 = 10! / 3!7!
Answer:
120
14. Permutation vs. Combination
A very important question is:
Does order matter?
If yes, use permutation.
If no, use combination.
Example
Selecting 3 students for a committee:
ABC=ACB
Therefore, order does not matter.
Use:
nCr
But if assigning:
President
Vice President
Secretary
then:
ABC is not equal to ACB
because the positions are different.
Use:
nPr
15. Counting Example in Computer Engineering
Example 15: Selecting Faulty Components
A circuit board has 12 components. Four are defective. An engineer randomly selects
3 components.
What is the probability that all 3 selected components are defective?
Step 1: Total ways to select 3 components
There are 12 components:
12C3 = 12! / 3!9! = 12(11)(10)/ 3(2)(1) = 220
Step 2: Favorable selections
There are 4 defective components, and we need to select 3:
4C3 =4
Step 3: Probability
P(all defective)= favorable outcomes / total outcomes = 220 / 4
Answer:
P≈0.0182
or approximately 1.82%.
PART IV — RULES OF PROBABILITY
16. Basic Probability Rules
Several rules are fundamental:
Rule 1: Probability Range
0≤P(A)≤1
Rule 2: Probability of the Sample Space
P(S)=1
Rule 3: Probability of an Impossible Event
P(∅ )=0
Rule 4: Complement Rule
P(Ac)=1−P(A)
Rule 5: Addition Rule
P(A∪B)=P(A)+P(B)−P(A∩B)
Rule 6: Multiplication Rule
P(A∩B)=P(A)P(B∣A)
Rule 7: Conditional Probability
P(B∣A)= P(A∩B)/ P(A)
17. Addition Rule
The addition rule is used when the question involves "A or B."
P(A∪B)=P(A)+P(B)−P(A∩B)
If the events are mutually exclusive:
P(A∩B)=0
so:
P(A∪B)=P(A)+ P(B)
Example 16: Network Failures
Suppose the probability that Network A fails is 0.10 and the probability that Network
B fails is 0.15. The probability that both fail is 0.03.
Find the probability that at least one network fails.
Step 1:
P(A)=0.10 P(B)=0.15 P(A∩B)=0.03
Step 2:
Apply the addition rule:
P(A∪B)=P(A)+P(B)−P(A∩B)
Step 3:
=0.10 + 0.15 − 0.03 = 0.22
Answer:
0.22
There is a 22% probability that at least one network fails.
18. Multiplication Rule
The multiplication rule is used when the question involves "A and B."
For dependent events:
P(A∩B)=P(A)P(B∣A)
For independent events:
P(A∩B)=P(A)P(B)
Example 17: Two Sensors
Two independent sensors have probabilities of correctly detecting an object of:
P(A)=0.90
and
P(B)=0.80
What is the probability that both sensors correctly detect the object?
Step 1:
Because the sensors are independent:
P(A∩B)=P(A)P(B)
Step 2:
=0.90(0.80) =0.72
Answer:
0.72
or 72%.
19. Conditional Probability
Conditional probability measures the probability of an event given that another
event has already occurred.
It is written:
P(A∣B)
and read:
"The probability of A given B."
The formula is:
P(A∣B)= P(A∩B)/ P(B)
Example 18: Defective Components
A manufacturing company produces 1,000 components.
100 are defective.
40 of the defective components come from Machine A.
Machine A produced 400 components.
If a component is known to have come from Machine A, what is the probability that it
is defective?
Step 1:
Define:
D=defective A=produced by Machine A
We need:
P(D∣A)
Step 2:
Use the conditional probability formula:
P(D∣A)= P(D∩A) / P(A)
Step 3:
Since there are 40 defective components from Machine A:
P(D∩A)= 40 / 1000
Since 400 components came from Machine A:
P(A)= 400 / 1000
Step 4:
P(D∣A)= (40/1000) / (400/1000) = 0.10
Therefore, a component known to have come from Machine A has a 10% probability
of being defective.
20. Law of Total Probability
When an event can occur through several different categories, the total probability can
be calculated by adding the probabilities of each pathway.
For two events:
P(A)=P(A∣B)P(B)+ P(A∣Bc)P(Bc)
Example 19: Components from Two Machines
Machine A produces 60% of a company's components and Machine B produces 40%.
The defective rates are:
P(D∣A)=0.02 P(D∣B)=0.05
What is the overall probability that a randomly selected component is defective?
Step 1:
Machine A:
P(A)=0.60
Machine B:
P(B)=0.40
Step 2:
Defective probability through Machine A:
P(D∣A)P(A) =0.02(0.60) =0.012
Step 3:
Defective probability through Machine B:
P(D∣B)P(B) =0.05(0.40) =0.020
Step 4: Add
P(D)=0.012+0.020 =0.032
Answer:
P(D)=0.032
or 3.2%.
21. Bayes' Theorem
Bayes' theorem allows us to reverse conditional probabilities.
The formula is:
P(A∣B)= P(B∣A)P(A)/ P(B)
It is particularly useful in:
cybersecurity;
fault diagnosis;
medical diagnosis;
machine learning;
artificial intelligence;
spam detection;
intrusion detection.
Step 1: Define events
Let:
M=connection is malicious
F=system flags connection
Given:
P(M)=0.01 P(Mc)=0.99 P(F∣M)=0.95 P(F∣Mc)=0.05
We need:
P(M∣F)
Step 2: Calculate P(F)
Using total probability:
P(F)=P(F∣M)P(M)+ P(F∣Mc)P(Mc)
Substitute:
P(F)=(0.95)(0.01)+(0.05)(0.99) =0.0095+0.0495 =0.059
Step 3: Apply Bayes' theorem
P(M∣F)= )P(F∣M)P(M) / P(F) = (0.95)(0.01)/ 0.059 =
0.0095 / 0.059 ≈0.1610
Answer:
P(M∣F)≈0.161
or approximately 16.1%.
Important observation
Even though the detection system is 95% effective at detecting malicious connections,
a flagged connection has only about a 16.1% probability of actually being
malicious because malicious connections are relatively rare.
This is an important concept in cybersecurity and machine learning.
PART V — INTEGRATED COMPUTER ENGINEERING EXAMPLES
Example 21: Packet Transmission
Suppose a packet has a 3% probability of being lost.
What is the probability that three independently transmitted packets are all
successfully received?
Step 1: Probability of successful transmission
P(S)=1−0.03 =0.97
Step 2: Three independent successful transmissions
P(S1 ∩S2 ∩S3 )=(0.97)3
Step 3:
(0.97)3 = 0.912673
Answer:
0.912673
or approximately 91.27%.
Example 22: Probability of At Least One Packet Loss
Using the same situation, what is the probability that at least one of three packets is
lost?
Step 1: Use the complement.
The complement of "at least one packet is lost" is:
all three packets are successfully received.
From Example 21:
P(all successful)=0.912673
Step 2:
P(at least one loss)= 1−0.912673 = 0.087327
Answer:
0.087327
or approximately 8.73%.
Example 23: Selecting RAM Modules
A warehouse contains 20 RAM modules:
15 are working
5 are defective
Three modules are selected without replacement.
What is the probability that exactly two are working?
Step 1: Total selections
20C3 = 20!/ 3!17! = 20(19)(18) / 6 = 1140
Step 2: Favorable selections
We need:
2 working from 15
1 defective from 5
Therefore:
15C2 × 5C1
Calculate:
15 C2 =215(14) =105
and
5C1 =5
Thus:
105(5)= 525
Step 3: Probability
P= 525 / 1140 ≈0.4605
or approximately 46.05%.
Example 24: Computer System Failure
A computer system has three independent components. Their probabilities of failure
are:
P(A)=0.02 P(B)=0.03 P(C)=0.01
What is the probability that all three components operate successfully?
Step 1: Find success probabilities
For A:
P(Ac)=1−0.02=0.98
For B:
P(Bc)=1−0.03=0.97
For C:
P(Cc)=1−0.01=0.99
Step 2: Multiply because the components are independent
P(all work)=(0.98)(0.97)(0.99)
Step 3:
=0.941094
Answer:
0.941094
or approximately 94.11%.