2.5 Calculating the Mean

COS2621 - Computer Organisation · 2. Performance Issues

Performance Issues

Calculating the Mean

The mean, commonly known as the average, is a key statistical measure used to summarise a set of data. In computing, the mean is crucial for performance analysis, helping to evaluate the efficiency of algorithms and systems.

Definition of Mean

The mean is calculated by adding all the values in a dataset and then dividing by the number of values. The formula for the mean is:

Mean (μ) = (Σx) / n

Where:

  • Σx is the sum of all values in the dataset.
  • n is the number of values.

Example Calculation

Suppose you have the following five execution times (in milliseconds) for a program: 120, 135, 145, 130, and 125. To calculate the mean:

  1. First, sum the values: 120 + 135 + 145 + 130 + 125 = 655.
  2. Next, count the number of values: 5.
  3. Finally, divide the sum by the count: 655 / 5 = 131.

The mean execution time is 131 milliseconds. A harmonic mean is a good candidate for comparing the execution time performance of several systems.

Weighted Mean

In some cases, you may need to calculate a weighted mean, where different values contribute differently to the final average. The weighted mean is calculated using the formula:

Weighted Mean (W) = (Σ(w_i * x_i)) / Σw_i

Where:

  • w_i is the weight of each value.
  • x_i is the value.

Example of Weighted Mean

Consider the following scores and their corresponding weights:

  • Score 1: 80 (weight 2)
  • Score 2: 90 (weight 3)
  • Score 3: 70 (weight 1)

To calculate the weighted mean:

  1. Calculate the weighted scores: (80 * 2) + (90 * 3) + (70 * 1) = 160 + 270 + 70 = 500.
  2. Calculate the total weight: 2 + 3 + 1 = 6.
  3. Now, divide the total weighted score by the total weight: 500 / 6 = 83.33.

The weighted mean score is 83.33. Use the weighted mean when different data points have different levels of importance.

Watch out: A common mistake is to forget to divide by the correct number of values. Ensure that you always count the number of values accurately.

Performance Metrics in Computing

Understanding different types of means is essential for performance measurement. For example, the arithmetic mean gives equal weight to all values in the dataset. This can be particularly useful when comparing the performance of multiple systems.

Benchmark Suites

Benchmark suites are important in performance evaluation. The best known of the SPEC benchmark suites is SPEC CPU2006. These benchmarks help in assessing the performance of different computer architectures.

Summary

  • The mean is calculated by summing values and dividing by the count.
  • The weighted mean accounts for different levels of importance among data points.
  • Arithmetic mean gives equal weight to all values.
  • Benchmark suites like SPEC CPU2006 are significant for performance evaluation.

Check your understanding

  • What is the mean of the following numbers: 10, 20, 30, 40, 50?
  • How do you calculate the weighted mean for scores of 60, 70, and 80 with weights of 1, 2, and 3 respectively?
  • Why is it important to use the correct number of values when calculating the mean?
  • What is the best known of the SPEC benchmark suites?

Test yourself

4 quick questions on this lesson. Pick an answer to see if you're right.

  1. 1. What is the weighted mean of scores 80, 90, and 70 with weights 2, 3, and 1 respectively?

  2. 2. What is the formula for calculating the mean?

  3. 3. What is a common mistake when calculating the mean?

  4. 4. In the context of performance analysis, why is the mean important?