What does Design-Token Algebra conclude, in numbers, about “Method: Three Measures of Multi-Site Visual Drift, Grades of Evidence and the Cai-Fen Module of the Yingzao Fashi”?
Answer: Chapter 1 fixes the book-wide sample: across the 30 sites of the invented brand group Hengyu, four family primaries have become 16 live colours, 24 sites have a role beyond a ΔE00 tolerance of 2.0, and 2,210 of 9,400 colour declarations are hard-coded; deviation rate and colour difference have a rank correlation of only 0.608; and the best-looking design is also the most trusted with a probability of only 0.202 when the two are unrelated.
Scope of the numbers: All brands, sites, colours and ratings are invented, every calculation comes from the book's programs, and legal matters are described only in general terms, not as legal advice. Each hypothesis states what would refute it.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 00, 16, 2.0, 2210, 24, 30
| Sharma et al. (2005) pairs 1 and 17 reproduced: 2.0425, 27.1492 | |||||||||
| shared: | accent #B8913F | text #1B1B20 | muted #6B6B76 | surface #F7F5F0 | border #E4E2DC | ||||
| primary: boutique #8C2F39 | report #1F5FA8 | course #2E7D5B | card #6B4FA0 | ||||||
| site builder | primary | dE00(pri) | worst role | worst dE00 | roles>2.0 | decl | hard | dev.rate | |
| B01 | agency | #8C2F39 | 0.00 | surface | 1.37 | 0 | 165 | 70 | 0.424 |
| B02 | in-house | #8C2F39 | 0.00 | muted | 6.85 | 1 | 367 | 46 | 0.125 |
| B03 | in-house | #7D323F | 4.50 | primary | 4.50 | 2 | 180 | 18 | 0.100 |
| B04 | agency | #8C2F39 | 0.00 | muted | 3.92 | 1 | 443 | 138 | 0.312 |
| B05 | agency | #783348 | 8.28 | border | 9.93 | 2 | 228 | 72 | 0.316 |
| B06 | in-house | #8C2F39 | 0.00 | text | 3.40 | 1 | 191 | 27 | 0.141 |
| B07 | in-house | #863036 | 1.50 | primary | 1.50 | 0 | 430 | 62 | 0.144 |
| B08 | template | #900A05 | 12.27 | text | 14.88 | 4 | 333 | 125 | 0.375 |
| R01 | agency | #1F5FA8 | 0.00 | border | 4.37 | 2 | 239 | 72 | 0.301 |
| R02 | agency | #114F91 | 5.75 | primary | 5.75 | 1 | 336 | 121 | 0.360 |
| R03 | in-house | #1F5FA8 | 0.00 | border | 3.38 | 1 | 346 | 40 | 0.116 |
| R04 | agency | #4E67B6 | 7.10 | primary | 7.10 | 3 | 220 | 94 | 0.427 |
| R05 | in-house | #1F5FA8 | 0.00 | primary | 0.00 | 0 | 319 | 38 | 0.119 |
| R06 | template | #4061B0 | 4.68 | text | 5.83 | 3 | 376 | 252 | 0.670 |
| R07 | in-house | #2561B6 | 2.13 | border | 4.10 | 2 | 454 | 68 | 0.150 |
| R08 | in-house | #1F5FA8 | 0.00 | accent | 3.10 | 1 | 408 | 58 | 0.142 |
| C01 | agency | #55836F | 7.41 | text | 8.03 | 3 | 279 | 79 | 0.283 |
| C02 | in-house | #2E7D5B | 0.00 | muted | 6.10 | 1 | 152 | 19 | 0.125 |
| C03 | agency | #508771 | 6.99 | muted | 7.36 | 3 | 394 | 166 | 0.421 |
| C04 | in-house | #337853 | 2.35 | primary | 2.35 | 1 | 446 | 57 | 0.128 |
| C05 | in-house | #2E7D5B | 0.00 | primary | 0.00 | 0 | 242 | 24 | 0.099 |
| C06 | in-house | #2E7D5B | 0.00 | surface | 2.51 | 1 | 402 | 48 | 0.119 |
| C07 | in-house | #2E7D5B | 0.00 | accent | 2.62 | 1 | 217 | 18 | 0.083 |
| K01 | in-house | #6B4FA0 | 0.00 | primary | 0.00 | 0 | 449 | 34 | 0.076 |
Show the full program
# Chapter 1. p10: The book-wide sample - Hengyu's 30 sites, their drifted colours and token deviations.
# Everything here is invented. Hengyu is a fictional brand group. Shared roles use the Hengyu primitives
# (gold.500, ink.900, ink.500, ink.050, ink.100); the primary is the family brand of the site. Each
# site's "live" colours are drawn from a seeded drift model (seed 140); nothing here is measured.
# Drift model: a site built by builder X keeps a role bound to its token with probability KEEP[X];
# otherwise the role's colour is moved in OKLCH by Gaussian steps scaled by SPREAD[X].
# Colour difference: CIEDE2000 on CIELAB (D65), as in Sharma, Wu & Dalal (2005); the program first
# checks itself against two of their published test pairs. Registered tolerance: Delta E00 <= 2.0.
import math
import random
import statistics
fs = math.fsum
M = ((0.4124564, 0.3575761, 0.1804375), (0.2126729, 0.7151522, 0.0721750), (0.0193339, 0.1191920, 0.9503041))
WHITE = (0.95047, 1.0, 1.08883)
def dec(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
def enc(v):
v = min(1.0, max(0.0, v))
return 12.92 * v if v <= 0.0031308 else 1.055 * v ** (1 / 2.4) - 0.055
def hex2rgb(h):
return tuple(int(h[i:i + 2], 16) / 255 for i in (1, 3, 5))
def rgb2hex(rgb):
return "#" + "".join("{:02X}".format(round(min(1.0, max(0.0, c)) * 255)) for c in rgb)
def lab(h):
lin = [dec(c) for c in hex2rgb(h)]
xyz = [fs(m * v for m, v in zip(row, lin)) / w for row, w in zip(M, WHITE)]
def f(t):
return t ** (1 / 3) if t > (6 / 29) ** 3 else t / (3 * (6 / 29) ** 2) + 4 / 29
fx, fy, fz = (f(t) for t in xyz)
return (116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz))
def de00(p, q):
(L1, a1, b1), (L2, a2, b2) = p, q
cb = (math.hypot(a1, b1) + math.hypot(a2, b2)) / 2
g = 0.5 * (1 - math.sqrt(cb ** 7 / (cb ** 7 + 25 ** 7)))
a1p, a2p = (1 + g) * a1, (1 + g) * a2
c1, c2 = math.hypot(a1p, b1), math.hypot(a2p, b2)
h1 = math.degrees(math.atan2(b1, a1p)) % 360 if c1 else 0.0
h2 = math.degrees(math.atan2(b2, a2p)) % 360 if c2 else 0.0
dh = 0.0
if c1 * c2:
dh = h2 - h1
dh = dh - 360 if dh > 180 else dh + 360 if dh < -180 else dh
dl, dc = L2 - L1, c2 - c1
dhh = 2 * math.sqrt(c1 * c2) * math.sin(math.radians(dh / 2))
lm, cm = (L1 + L2) / 2, (c1 + c2) / 2
if c1 * c2 == 0:
hm = h1 + h2
elif abs(h1 - h2) <= 180:
hm = (h1 + h2) / 2
else:
hm = (h1 + h2 + 360) / 2 if h1 + h2 < 360 else (h1 + h2 - 360) / 2
t = fs([1, -0.17 * math.cos(math.radians(hm - 30)), 0.24 * math.cos(math.radians(2 * hm)),
0.32 * math.cos(math.radians(3 * hm + 6)), -0.20 * math.cos(math.radians(4 * hm - 63))])
rot = 30 * math.exp(-((hm - 275) / 25) ** 2)
rc = 2 * math.sqrt(cm ** 7 / (cm ** 7 + 25 ** 7))
sl = 1 + 0.015 * (lm - 50) ** 2 / math.sqrt(20 + (lm - 50) ** 2)
sc, sh = 1 + 0.045 * cm, 1 + 0.015 * cm * t
rt = -math.sin(math.radians(2 * rot)) * rc
return math.sqrt(fs([(dl / sl) ** 2, (dc / sc) ** 2, (dhh / sh) ** 2, rt * (dc / sc) * (dhh / sh)]))
def oklch_of(h):
r, g, b = (dec(c) for c in hex2rgb(h))
lms = (fs([0.4122214708 * r, 0.5363325363 * g, 0.0514459929 * b]),
fs([0.2119034982 * r, 0.6806995451 * g, 0.1073969566 * b]),
fs([0.0883024619 * r, 0.2817188376 * g, 0.6299787005 * b]))
l_, m_, s_ = (math.copysign(abs(v) ** (1 / 3), v) for v in lms)
L = fs([0.2104542553 * l_, 0.7936177850 * m_, -0.0040720468 * s_])
a = fs([1.9779984951 * l_, -2.4285922050 * m_, 0.4505937099 * s_])
bb = fs([0.0259040371 * l_, 0.7827717662 * m_, -0.8086757660 * s_])
return L, math.hypot(a, bb), math.degrees(math.atan2(bb, a)) % 360
def hex_of_oklch(L, C, H):
a, b = C * math.cos(math.radians(H)), C * math.sin(math.radians(H))
l_, m_, s_ = (fs([L, 0.3963377774 * a, 0.2158037573 * b]), fs([L, -0.1055613458 * a, -0.0638541728 * b]),
fs([L, -0.0894841775 * a, -1.2914855480 * b]))
l, m, s = l_ ** 3, m_ ** 3, s_ ** 3
lin = (fs([4.0767416621 * l, -3.3077115913 * m, 0.2309699292 * s]),
fs([-1.2684380046 * l, 2.6097574011 * m, -0.3413193965 * s]),
fs([-0.0041960863 * l, -0.7034186147 * m, 1.7076147010 * s]))
return rgb2hex(tuple(enc(v) for v in lin))
# Self-check against Sharma, Wu & Dalal (2005), test pairs 1 and 17.
for p, q, want in (((50, 2.6772, -79.7751), (50, 0, -82.7485), 2.0425),
((50, 2.5, 0), (73, 25, -18), 27.1492)):
assert abs(de00(p, q) - want) < 5e-5, (p, q, de00(p, q))
ROLES = ("primary", "accent", "text", "muted", "surface", "border")
CANON = {"accent": "#B8913F", "text": "#1B1B20", "muted": "#6B6B76",
"surface": "#F7F5F0", "border": "#E4E2DC"}
BRAND = {"B": "#8C2F39", "R": "#1F5FA8", "C": "#2E7D5B", "K": "#6B4FA0"} # primary: one brand per family
FAMILY = {"B": "boutique", "R": "report", "C": "course", "K": "card"}
SITES = [f + "{:02d}".format(i) for f, n in (("B", 8), ("R", 8), ("C", 7), ("K", 7)) for i in range(1, n + 1)]
KEEP = {"in-house": 0.85, "agency": 0.55, "template": 0.30}
SPREAD = {"in-house": 0.6, "agency": 1.0, "template": 1.8}
TOL = 2.0
def canon_of(code, role):
return BRAND[code[0]] if role == "primary" else CANON[role]
def build(seed=140):
rng = random.Random(seed)
out = []
for code in SITES:
builder = rng.choices(("in-house", "agency", "template"), weights=(5, 3, 2))[0]
live = {}
for role in ROLES:
canon = canon_of(code, role)
if rng.random() < KEEP[builder]:
live[role] = canon
continue
L, C, H = oklch_of(canon)
s = SPREAD[builder]
L2 = min(0.99, max(0.05, L + rng.gauss(0, 0.035 * s)))
C2 = max(0.0, C + rng.gauss(0, 0.025 * s))
live[role] = hex_of_oklch(L2, C2, H + rng.gauss(0, 7 * s))
decl = rng.randint(140, 460)
hard = round(decl * (1 - KEEP[builder]) * rng.uniform(0.5, 1.0))
out.append((code, builder, live, decl, hard))
return out
if __name__ == "__main__":
print("Sharma et al. (2005) pairs 1 and 17 reproduced: 2.0425, 27.1492")
print("shared: " + " ".join("{} {}".format(r, v) for r, v in CANON.items()))
print("primary: " + " ".join("{} {}".format(FAMILY[k], v) for k, v in BRAND.items()))
print("site builder primary dE00(pri) worst role worst dE00 roles>2.0 decl hard dev.rate")
rows = build()
worst_all, fails, rates, pri = [], 0, [], []
off_role = {r: 0 for r in ROLES}
for code, builder, live, decl, hard in rows:
des = {r: de00(lab(live[r]), lab(canon_of(code, r))) for r in ROLES}
wr = max(ROLES, key=lambda r: des[r])
n_over = sum(1 for r in ROLES if des[r] > TOL)
for r in ROLES:
off_role[r] += des[r] > TOL
fails += n_over > 0
worst_all.append(des[wr])
pri.append(des["primary"])
rates.append(hard / decl)
print("{:4s} {:9s} {} {:9.2f} {:10s} {:10.2f} {:9d} {:4d} {:4d} {:8.3f}".format(
code, builder, live["primary"], des["primary"], wr, des[wr], n_over, decl, hard, hard / decl))
nb = {b: sum(1 for r in rows if r[1] == b) for b in KEEP}
print("builders: " + ", ".join("{} {}".format(b, n) for b, n in nb.items()))
print("distinct live primaries: {} for 4 family brands; exact family primary on {} sites".format(
len({r[2]["primary"] for r in rows}), sum(1 for r in rows if r[2]["primary"] == BRAND[r[0][0]])))
print("sites with at least one role over dE00 2.0: {} of 30".format(fails))
print("roles over tolerance, by role: " + ", ".join("{} {}".format(r, n) for r, n in off_role.items()))
print("primary dE00: median {:.2f}, max {:.2f}; worst-role dE00: median {:.2f}, max {:.2f}".format(
statistics.median(pri), max(pri), statistics.median(worst_all), max(worst_all)))
tot_d, tot_h = sum(r[3] for r in rows), sum(r[4] for r in rows)
print("colour declarations {:,}; hard-coded {:,}; pooled deviation rate {:.3f}; median site rate {:.3f}"
.format(tot_d, tot_h, tot_h / tot_d, statistics.median(rates)))Single source and citation
Fan, Y. (2026). Design-Token Algebra across Thirty Sites, Perceptually Uniform Colour Spaces and the Millisecond Science of Brand-Authority First Impressions (Version 0.1.0), Chapter 1: Method: Three Measures of Multi-Site Visual Drift, Grades of Evidence and the Cai-Fen Module of the Yingzao Fashi. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-140 · v0.1.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026140,
author = {Fan, Yafu},
title = {Design-Token Algebra across Thirty Sites, Perceptually Uniform Colour Spaces and the Millisecond Science of Brand-Authority First Impressions},
year = {2026},
publisher = {5D Library},
edition = {0.1.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 2 · Token Algebra: Three Layers, Themes as Functions and the Dependency Graph of Thirty Sites
- Chapter 3 · Perceptually Uniform Colour Spaces: From sRGB to CIELAB, CIEDE2000 and OKLab
- Chapter 4 · Perceptually Uniform Ramps: Lightness Steps, Contrast Constraints, Gamut Clipping and Dark-Theme Inversion
- Chapter 5 · The 50-Millisecond First Impression: Exposure, Complexity, Prototypicality and the Distance to a Sale
- Chapter 6 · Governing Thirty Sites: Release, Drift Detection, Per-Brand Re-Theming, Audit and Rollback
- Chapter 7 · Playbooks for the Four Kinds of Site, and the Distillation Spec for the Four Kits
- Chapter 8 · Practice: Unifying the Palettes of Five Representative Hengyu Sites, with a Pre-Registered First-Impression Test