A mean summarizes the total divided by the count. A median describes the middle of an ordered sample. Percentiles describe a position in that distribution, with conventions that should be stated. Averages can hide a small number of very slow requests.
Variance and spread help describe how consistent observations are. For latency, report the workload, sample size, and relevant tail behavior as well as the mean. Separate queue time from execution time when possible.
Do not mix failed requests into a latency report without explaining how they were handled. Excluding every timeout can make an unreliable service appear faster. Quality, failure rate, and latency should be interpreted together.
Exercise: compare two synthetic latency sets with the same mean but different tails. Add timeouts and decide how to report them.
Check: the report includes sample size, percentile convention, and failure rate rather than a single flattering average.
Guided workshop: calculate similarity and uncertainty
A vector represents numerical features in an agreed order. A dot product multiplies matching coordinates and sums them. Cosine similarity divides by vector lengths, so it compares direction. It does not establish that a retrieved passage is factually sufficient to answer a question.
# academy-check
from math import sqrt, ceil
def cosine(a, b):
if len(a) != len(b) or not a:
raise ValueError("matching nonempty vectors required")
lengths = sqrt(sum(x*x for x in a)) * sqrt(sum(x*x for x in b))
return sum(x*y for x, y in zip(a, b)) / lengths if lengths else 0.0
assert cosine([1, 0], [1, 0]) == 1
assert cosine([1, 0], [0, 1]) == 0
assert cosine([0, 0], [1, 0]) == 0
latencies = [20, 20, 30, 30, 40, 40, 50, 60, 100, 900]
p95 = sorted(latencies)[ceil(.95 * len(latencies)) - 1]
assert p95 == 900
assert sum(latencies) / len(latencies) == 129
This lesson defines the zero-vector result as zero so retrieval can ignore an empty representation. Other libraries may reject zero vectors. Check that choice explicitly when replacing the function. The percentile uses the nearest-rank convention; different interpolation rules can yield another value on a tiny dataset.
Worked probability case: suppose 10 of 100 tickets are urgent. A classifier finds 8 of those 10 and incorrectly flags 18 of the other 90. Recall is 8/10 = 80%; precision is 8/26 ≈ 31%. The headline recall hides that most alerts are false positives. Decide whether the operator can review 26 flags and whether missing two urgent tickets is acceptable.
Exercise: change the urgent-ticket prevalence to 1 in 100 while keeping the same sensitivity and false-positive rate. Compute expected counts rather than pretending fractional expectations are observed tickets. Precision becomes roughly 0.8 / (0.8 + 19.8), about 3.9%. A metric can change because the deployment population changed even when conditional behavior stayed similar.
Checkpoint: report sample size, units, percentile convention, and both successful and failed requests in latency analysis. Ten observations cannot support a confident statement about rare tail failures. Keep a raw measurement table so another learner can reproduce your calculations.