static patternMatchVariance(counters, pattern, maxIndividualVariance) {
			let numCounters = counters.length;
			let total = 0;
			let patternLength = 0;
			for (let i = 0; i < numCounters; i++) {
				total += counters[i];
				patternLength += pattern[i];
			}
			if (total < patternLength) {
				// If we don't even have one pixel per unit of bar width, assume this
				// is too small to reliably match, so fail:
				return /*Float.POSITIVE_INFINITY*/ Infinity;
			}
			// We're going to fake floating-point math in integers. We just need to use more bits.
			// Scale up patternLength so that intermediate values below like scaledCounter will have
			// more "significant digits".
			let unitBarWidth = total / patternLength;
			maxIndividualVariance *= unitBarWidth;
			let totalVariance = 0.0;
			for (let x = 0; x < numCounters; x++) {
				let counter = counters[x];
				let scaledPattern = pattern[x] * unitBarWidth;
				let variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
				if (variance > maxIndividualVariance) {
					return /*Float.POSITIVE_INFINITY*/ Infinity;
				}
				totalVariance += variance;
			}
			return totalVariance / total;
		}
Determines how closely a set of observed counts of runs of black/white
values matches a given target pattern. This is reported as the ratio of
the total variance from the expected pattern proportions across all
pattern elements, to the length of the pattern.

@param counters observed counters
@param pattern expected pattern
@param maxIndividualVariance The most any counter can differ before we give up
@return ratio of total variance between counters and pattern compared to total pattern size