Z-Score: How Rare Is This Pattern?
The z-score measures how unusual a window is compared to random expectation.
z = (expected_entropy − actual_entropy) ÷ σ
Where σ (standard deviation) measures how much entropy normally varies in random windows. Here's how it's calculated:
σ = √( (1/n) × Σ (Hᵢ − H̄)² )
Step by step:
Step 1: Generate thousands of random NPUBs
Step 2: Measure each window's entropy Hᵢ
Step 3: Calculate the average (mean) entropy H̄ = 3.57 bits for W=16
Step 4: For each window, compute how far it deviates from the mean: (Hᵢ − H̄)
Step 5: Square each deviation: (Hᵢ − H̄)² — squaring makes all values positive and emphasizes outliers
Step 6: Average all squared deviations, then take the square root: that's σ
For W=16: H̄ = 3.571 bits, σ = 0.187 bits
A random 16-character window has ~3.57 bits of entropy on average, with σ=0.187. If we find one with only 1.5 bits, that's (3.571 − 1.5) ÷ 0.187 = z=11.1 — eleven standard deviations below the mean.
z = 2 → 2σ below mean → top 2.3% of windows (1 in 43)
z = 4 → 4σ below mean → top 0.003% (1 in 33,000)
z = 8 → 8σ below mean → astronomically rare
Higher z = harder for an attacker to replicate by chance. This is our anti-forgery metric.
Unique Characters: How Recognizable Is This?
A 16-character window with only 3 unique characters looks like:
[p][p][q][p]
[p][q][q][p]
[q][p][p][q]
[p][q][p][p]
A 16-character window with 10 unique characters looks like:
[7][k][2][x]
[m][v][0][z]
[3][r][5][k]
[8][j][q][n]
Same window size. Same z-score. But one is instantly recognizable and the other looks like noise. Fewer unique characters = bigger blocks of the same color = more recognizable to humans.
Quality: The Best of Both Worlds
quality = 10·log₁₀(z ÷ (unique_chars)³) dB
Logarithmic scale — like audio decibels. Every 10 dB is a 10× difference in raw quality. This spreads small values into a readable range:
W=16, 3 chars
8.0
3
−5.3 dB
★ recognizable + rare
W=49, 8 chars
5.0
8
−20.1 dB
rare but unrecognizable
W=16, 2 chars
5.0
2
−2.0 dB
★ very recognizable
W=25, 7 chars
6.0
7
−17.6 dB
meh
The scanner optimizes for the highest quality score. This naturally selects patterns that are both rare (high z) and human-recognizable (few unique chars).