A mean is the arithmetic average of numerical measurements: add the values and divide by their count. In an experiment, averaging repeated measurements reduces the influence of unpredictable variation and usually moves the result closer to the underlying expectation. section 2.2.1 section 2.2
For a production decision, compare means rather than isolated observations. Measure execution cost repeatedly on each exchange, calculate one mean per exchange, and select the exchange with the lower mean when lower cost is better. Replication does not eliminate variation, but it makes the comparison more reliable. section 2.2.1
Three execution-cost measurements
Three ASDAQ measurements are 12.27626589, 10.14537192, and 12.62390111. Their mean is 11.681846307513723, which is closer to the expectation of 12 mips than two of the three individual measurements. With 300 measurements, the reported means are 12.000257642551059 for ASDAQ and 10.051095649188758 for BYSE. section 2.2.1
Listing 2.4 Aggregate measurement
def aggregate_measurement(exchange, num_individual_measurements):
individual_measurements = np.array([
trading_system(exchange) #1
for _ in range(num_individual_measurements) #2
])
return individual_measurements.mean() #3
Implements an aggregate measurement by collecting repeated observations with NumPy and returning their mean. section 2.2.1
Listing 2.5 Aggregate measurement with SE
def aggregate_measurement_with_se(exchange, num_individual_measurements):
individual_measurements = np.array(
[trading_system(exchange) for _ in range(num_individual_measurements)]
) #1
aggregate_measurement = individual_measurements.mean() #2
sd_1 = individual_measurements.std() #3
se = sd_1 / np.sqrt(num_individual_measurements) #3
return aggregate_measurement, se
Extends the mean with a standard-error estimate, dividing the individual-measurement standard deviation by the square root of the replication count. section 2.2.1




























