Skip to content

Cumulative Distribution Function for Classifier Errors

A cumulative distribution function gives the probability that a random variable is at or below a threshold, so the value at the threshold itself counts. Lehman, Leighton, and Meyer define it in Section 19.3 of Mathematics for Computer Science: the probability density function of a random variable "measures the probability that R takes the value x, and the closely related cumulative distribution function CDF_R(x) measures the probability that R ≤ x." Definition 19.3.1 states "CDF_R(x) ::= Pr[R ≤ x]." For a discrete variable it is a running total of the density: "CDF_R(x) = Pr[R ≤ x] = Σ_{y ≤ x} Pr[R = y] = Σ_{y ≤ x} PDF_R(y)."

They add the end behavior, "lim_{x→∞} CDF_R(x) = 1 and lim_{x→−∞} CDF_R(x) = 0," and the practical point: "Both PDF_R and CDF_R capture the same information about R, so take your choice." Their Bernoulli example shows the shape of a discrete CDF: F_p(x) is 0 if x < 0, p if 0 ≤ x < 1, and 1 if 1 ≤ x. The value jumps at 0 and at 1, and at each jump the function already takes the higher value.

Try it by hand. A classifier scores 5 invented examples, and on each it is wrong with probability 1/5, independently. Let R be the number of wrong answers. The probability of exactly k errors is C(5, k) (1/5)^k (4/5)^(5−k), which gives 0.32768, 0.4096, 0.2048, 0.0512, 0.0064, and 0.00032 for k = 0 to 5. The CDF is their running total: 0.32768, 0.73728, 0.94208, 0.99328, 0.99968, and 1. So Pr[R ≤ 2] = 0.94208, the chance of at most 2 errors. Now change one word. The chance of fewer than 2 errors is Pr[R ≤ 1] = 0.73728, because for whole numbers "fewer than 2" and "at most 1" are the same event. The two answers differ by 0.2048, which is Pr[R = 2], exactly the mass at the threshold. Dropping the equality is the standard slip. The CDF also answers interval questions by subtraction: Pr[2 < R ≤ 4] = CDF(4) − CDF(2) = 0.99968 − 0.94208 = 0.0576, and Pr[R > 2] = 1 − CDF(2) = 181/3125 = 0.05792. Between whole numbers it is flat: CDF(1.9) = CDF(1) = 0.73728, and at x = 2 it jumps up by 0.2048 to 0.94208. It never falls and it ends at 1. I computed all of these in exact fractions, and the classifier and its error rate are invented.

The trap: swapping the threshold or the inequality without saying so. CDF(x) is the probability at or below x. "Fewer than x" is a different question for a discrete variable, and "above x" is 1 − CDF(x). A caution of my own, not from the section I read: the book's definition covers a random variable with real values, and for a continuous variable the point mass at the threshold is zero, so equality changes nothing there; the discrete case is where it matters.

Prof Rod's rule: state the threshold and whether equality is included, read "at most" as the CDF, and use subtraction for intervals.

Lehman, Leighton, and Meyer, Mathematics for Computer Science (MIT 6.042, 2018), Section 19.3, Definition 19.3.1, pp. 861–863