[latexpage]
初始数据
我们有三台机器(机器A、机器B、机器C),它们运行两个程序(P1、P2),原始执行时间如下:
程序 | 机器A执行时间 | 机器B执行时间 | 机器C执行时间 |
---|---|---|---|
P1 | 1秒 | 10秒 | 20秒 |
P2 | 1000秒 | 100秒 | 20秒 |
使用机器A作为基准
归一化时间计算
如果我们选择机器A作为基准,那么归一化后的执行时间将是:
程序 | 机器A执行时间 | 机器B执行时间 | 机器C执行时间 | 机器B的归一化时间 | 机器C的归一化时间 |
---|---|---|---|---|---|
P1 | 1秒 | 10秒 | 20秒 | 10 / 1 = 10 | 20 / 1 = 20 |
P2 | 1000秒 | 100秒 | 20秒 | 100 / 1000 = 0.1 | 20 / 1000 = 0.02 |
平均计算
- 算术平均:\[
\text{Arithmetic Mean of Normalized Time (Machine B)} = \frac{10 + 0.1}{2} = \frac{10.1}{2} = 5.05
\] \[
\text{Arithmetic Mean of Normalized Time (Machine C)} = \frac{20 + 0.02}{2} = \frac{20.02}{2} = 10.01
\] - 几何平均: \[
\text{Geometric Mean of Normalized Time (Machine B)} = \sqrt{10 \times 0.1} = \sqrt{1} = 1.0
\] \[
\text{Geometric Mean of Normalized Time (Machine C)} = \sqrt{20 \times 0.02} = \sqrt{0.4} \approx 0.63
\]
使用机器B作为基准
归一化时间计算
如果我们选择机器B作为基准,那么归一化后的执行时间将是:
程序 | 机器A执行时间 | 机器B执行时间 | 机器C执行时间 | 机器A的归一化时间 | 机器C的归一化时间 |
---|---|---|---|---|---|
P1 | 1秒 | 10秒 | 20秒 | 1 / 10 = 0.1 | 20 / 10 = 2 |
P2 | 1000秒 | 100秒 | 20秒 | 1000 / 100 = 10 | 20 / 100 = 0.2 |
平均计算
- 算术平均: \[
\text{Arithmetic Mean of Normalized Time (Machine A)} = \frac{0.1 + 10}{2} = \frac{10.1}{2} = 5.0\] \[
\text{Arithmetic Mean of Normalized Time (Machine C)} = \frac{2 + 0.2}{2} = \frac{2.2}{2} = 1.1
\] - 几何平均: \[
\text{Geometric Mean of Normalized Time (Machine A)} = \sqrt{0.1 \times 10} = \sqrt{1} = 1.0
\] \[
\text{Geometric Mean of Normalized Time (Machine C)} = \sqrt{2 \times 0.2} = \sqrt{0.4} \approx 0.63
\]
使用机器C作为基准
归一化时间计算
如果我们选择机器C作为基准,那么归一化后的执行时间将是:
程序 | 机器A执行时间 | 机器B执行时间 | 机器C执行时间 | 机器A的归一化时间 | 机器B的归一化时间 |
---|---|---|---|---|---|
P1 | 1秒 | 10秒 | 20秒 | 1 / 20 = 0.05 | 10 / 20 = 0.5 |
P2 | 1000秒 | 100秒 | 20秒 | 1000 / 20 = 50 | 100 / 20 = 5 |
平均计算
- 算术平均: \[
\text{Arithmetic Mean of Normalized Time (Machine A)} = \frac{0.05 + 50}{2} = \frac{50.05}{2} = 25.025
\] \[
\text{Arithmetic Mean of Normalized Time (Machine B)} = \frac{0.5 + 5}{2} = \frac{5.5}{2} = 2.75
\] - 几何平均: \[
\text{Geometric Mean of Normalized Time (Machine A)} = \sqrt{0.05 \times 50} = \sqrt{2.5} \approx 1.58
\] \[
\text{Geometric Mean of Normalized Time (Machine B)} = \sqrt{0.5 \times 5} = \sqrt{2.5} \approx 1.58
\]
重点解释
几何平均的一致性
我们可以看到,无论我们选择哪一台机器作为基准,几何平均值总是能够给出一个相对稳定的度量。具体对比数据如下:
- 机器B的几何平均值:
- 以机器A为基准:( $\approx 1.0$ )
- 以机器B为基准:( $\approx 0.63$ )
- 以机器C为基准:( $\approx 1.58$ )
- 机器C的几何平均值:
- 以机器A为基准:( $\approx 0.63$ )
- 以机器B为基准:( $\approx 0.63$ )
- 以机器C为基准:( $\approx 1.58$ )
算术平均的敏感性
算术平均的敏感性体现在当基准变化时,算术平均的结果会发生较大变动。具体对比数据如下:
- 机器B的算术平均值:
- 以机器A为基准:( $\approx 5.05$ )
- 以机器B为基准:( $\approx 1.1$ )
- 以机器C为基准:( $\approx 2.75$ )
- 机器C的算术平均值:
- 以机器A为基准:( $\approx 10.01$ )
- 以机器B为基准:( $\approx 1.1$ )
- 以机器C为基准:( $\approx 25.025$ )
总结
通过对比数据可以看出:
- 几何平均的一致性:无论选择哪台机器作为基准,几何平均值的变化较小,反映了不同机器之间相对稳定的性能比较。
- 算术平均的敏感性:当基准变化时,算术平均值会有较大的变化,这说明算术平均容易受到极端值的影响,并且不如几何平均稳定。
因此,在评估不同机器的相对性能时,几何平均提供了一个更一致、更可靠的度量方法。