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 #B8913Ftext #1B1B20muted #6B6B76surface #F7F5F0border #E4E2DC
primary: boutique #8C2F39report #1F5FA8course #2E7D5Bcard #6B4FA0
site builderprimarydE00(pri)worst roleworst dE00roles>2.0declharddev.rate
B01agency#8C2F390.00surface1.370165700.424
B02in-house#8C2F390.00muted6.851367460.125
B03in-house#7D323F4.50primary4.502180180.100
B04agency#8C2F390.00muted3.9214431380.312
B05agency#7833488.28border9.932228720.316
B06in-house#8C2F390.00text3.401191270.141
B07in-house#8630361.50primary1.500430620.144
B08template#900A0512.27text14.8843331250.375
R01agency#1F5FA80.00border4.372239720.301
R02agency#114F915.75primary5.7513361210.360
R03in-house#1F5FA80.00border3.381346400.116
R04agency#4E67B67.10primary7.103220940.427
R05in-house#1F5FA80.00primary0.000319380.119
R06template#4061B04.68text5.8333762520.670
R07in-house#2561B62.13border4.102454680.150
R08in-house#1F5FA80.00accent3.101408580.142
C01agency#55836F7.41text8.033279790.283
C02in-house#2E7D5B0.00muted6.101152190.125
C03agency#5087716.99muted7.3633941660.421
C04in-house#3378532.35primary2.351446570.128
C05in-house#2E7D5B0.00primary0.000242240.099
C06in-house#2E7D5B0.00surface2.511402480.119
C07in-house#2E7D5B0.00accent2.621217180.083
K01in-house#6B4FA00.00primary0.000449340.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