Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

SRI KRISHNA COLLEGE OF ENGINEERING AND TECHNOLOGY

Kuniamuthur, Coimbatore, Tamilnadu, India


An Autonomous Institution, Affiliated to Anna University,
Accredited by NAAC with “A” Grade & Accredited by NBA (CSE, ECE, IT, MECH, EEE, CIVIL & MCT)

DEPARTMENT OF M.TECH-CSE

Course : Design and Analysis of Algorithms


Module : Fundamentals of Algorithm Analysis –
Empirical Analysis of Algorithm
Faculty :S.SREERAJ/AP-M.TECH/CSE

04/07/2023 1
EMPIRICAL ANALYSIS OF ALGORITHM

• How algorithms, both non-recursive and


recursive, can be analyzed mathematically.
• Though these techniques can be applied
success-fully to many simple algorithms, the
power of mathematics, even when enhanced
with more advanced.

04/07/2023 2
CONT…

• In fact, even some seemingly simple algorithms


have proved to be very difficult to analyze with
mathematical precision and certainty.
• The principal alternative to the mathematical
analysis of an algorithm’s efficiency is its
empirical analysis.
• This approach implies steps spelled out in the
following plan.

04/07/2023 3
GENERAL PLAN FOR THE EMPIRICAL
ANALYSIS OF ALGORITHM TIME EFFICIENCY
• Understand the experiment’s purpose.
• Decide on the efficiency metric M to be
measured and the measurement unit (an
operation count vs. a time unit).
• Decide on characteristics of the input sample
(its range, size, and so on).
• Prepare a program implementing the algorithm
(or algorithms) for the experimentation.
• Generate a sample of inputs.

04/07/2023 4
CONT…

• Run the algorithm (or algorithms) on the


sample’s inputs and record the data observed.
• Analyze the data obtained.
• Alternatively, you can implement one of several
known algorithms for generating (pseudo)
random numbers.
• The most widely used and thoroughly studied of
such algorithms is the linear congruential
method.

04/07/2023 5
ALGORITHM

ALGORITHM Random (n, m, seed, a, b)


//Generates a sequence of n pseudorandom
numbers according to the linear congruential
method
//Input: A positive integer n and positive integer
parameters m, seed, a, b
//Output: A sequence r1,...,rn of n pseudorandom
integers uniformly distributed among integer
values between 0 and m − 1

04/07/2023 6
CONT…

//Note: Pseudorandom numbers between 0 and 1


can be obtained by treating the integers
generated as digits after the decimal point
r0 ← seed
for i ← 1 to n do
 ri ← (a ∗ ri−1 + b) mod m

04/07/2023 7
TYPICAL SCATTER PLOTS

04/07/2023 8
CONT…

04/07/2023 9
IS EMPIRICAL ANALYSIS EASY OR
HARD?
Five aspects to consider in the process of
analysing an algorithm
• correctness,
• work done,
• space used,
• simplicity or clarity,
• optimality.

04/07/2023 10
DOING EMPIRICAL ANALYSIS

In order to do empirical analysis to verify and


expand on the theoretical analysis of an algorithm
we need to
• understand the theoretical analysis
• decide on what should be measured
• decide on appropriate hardware
• decide on an appropriate implementation
language
• decide on appropriate data structures

04/07/2023 11
• implement the algorithms
• implement some form of timing device
• create the input data sets necessary to produce
the measurements we need
• measure the performance of the algorithm on
the different input data sets created to meet our
aim
• interpret the results
• relate the results to the theoretical analysis

04/07/2023 12
ISSUES TO CONSIDER

• Empirical analysis introduces many more factors


that need to be controlled for in some way.
• It is much less obvious how to perform a
rigorous analysis in the presence of so many
factors.
• Practical considerations prevent complete
testing.

04/07/2023 13
MEASURES OF PERFORMANCE

• For the time being, we focus on sequential


algorithms.
• What is an appropriate measure of
performance?
• What is the goal?
• Possible measures

04/07/2023 14
MEASURING TIME

• User time
• System time
• Wallclock time

04/07/2023 15
REPRESENTATIVE OPERATION COUNTS

• In some cases, we may want to count


operations, rather than time
• What operations should we count?

04/07/2023 16
TEST SETS

• Example: Sorting

04/07/2023 17
COMPARING ALGORITHMS

• Given a performance measure and a test set,


the question still arises how to decide which
algorithm is “better.”
• We can do the comparison using some sort of
summary statistic.
• These statistics hide information useful for
comparison.

04/07/2023 18
ACCOUNTING FOR STOCHASTICITY

• Empirical Analysis
• Wallclock Time
• Parallel Processing
• Multiple Identical Runs
• Statistical Analysis

04/07/2023 19
PERFORMANCE PROFILES

• Comparison of Algorithms
• Visual Summary

04/07/2023 20
EXAMPLE PERFORMANCE PROFILE

04/07/2023 21
EMPIRICAL VERSUS THEORETICAL
ANALYSIS
• Sequential Algorithms
• Tuning of Implementational Details
• Parallel Algorithms
• Model of Computation
• Scalability

04/07/2023 22
04/07/2023 23
04/07/2023 24
04/07/2023 25

You might also like