5D Library › 双人相位耦合、双线性相容张量与时空网格博弈 · English

第一章 合盘评分是一个双线性形式

从口诀到矩阵

任何合盘规则都可以拆成两步。第一步把每个人编码成一个特征向量 xx:八字里五行的强弱、星盘里行星落入的星座与宫位、紫微命盘里主星的分布——编码可以千差万别,但最后都是一串数。第二步把两个人的向量合成一个分数。最一般而又最简单的合成方式是双线性形式

s(A,B)=xA⊤MxB=∑i,jxA,iMijxB,j,s(A, B) = x_A^{\top} M x_B = \sum_{i,j} x_{A,i}\, M_{ij}\, x_{B,j},

其中 MijM_{ij} 说明 A 的第 ii 个特征与 B 的第 jj 个特征「相生」(正)还是「相克」(负)、强度多大。传统口诀里的「生」「克」「合」「冲」,都可以读成 MM 的某些元素的符号与大小。

本章不问 xx 编码的特征是否真的与人的性情或关系有关——这是一个经验问题,第八章给出检验它的方案。本章只问:一旦评分写成这个形式,形式本身规定了什么。

对称部分与反对称部分

如果 MM 不对称,即 MAB≠MBAM_{AB} \neq M_{BA} 意义上的 M≠M⊤M \neq M^{\top},A 对 B 的分数与 B 对 A 的分数就不同。任何方阵都可以唯一地写成

M=S+K,S=12(M+M⊤),K=12(M−M⊤),M = S + K, \qquad S = \tfrac{1}{2}(M + M^{\top}), \qquad K = \tfrac{1}{2}(M – M^{\top}),

SS 对称,KK 反对称。由此立刻得到

s(A,B)+s(B,A)=2xA⊤SxB,s(A,B)−s(B,A)=2xA⊤KxB.s(A,B) + s(B,A) = 2\, x_A^{\top} S x_B, \qquad s(A,B) – s(B,A) = 2\, x_A^{\top} K x_B .

前者是两人共有的部分,后者是单向流动的部分:A 多得多少,B 就少得多少。因为 x⊤Kx=0x^{\top} K x = 0 对任何 xx 成立,一个人与自己的「单向」恒为零——单向性只存在于两个不同的人之间。

推导

三类关系的定义。 把两个方向的分数都为正的一对称为「双向相容」(合盘术语中的「正缘」),都为负的称为「双向相斥」(「孽缘」),符号相反的称为「单向」——一方的分数为正而另一方为负,在口语中常被称为「寄生」或「虹吸」。这只是给符号组合起的名字,不是关于真实关系的判断。

第一段程序随机抽取一个矩阵 MM,用比例 r=‖K‖/‖S‖r = \lVert K \rVert / \lVert S \rVert 控制它有多「单向」,然后抽取 20,000 对人,统计三类关系各占多少;再在 200 人的池子中,比较「按 A 给出的分数」与「按 A 收到的分数」各自选出的最佳对象是否为同一个人。

推导

# Chapter 1. A bilinear compatibility score and its two halves.
# Each person is a vector x of d = 6 traits, each uniform on [-1, 1]. The
# score of A towards B is s(A, B) = x_A' M x_B. If M is not symmetric,
# s(A, B) and s(B, A) differ. Every square M splits uniquely as M = S + K with
#   S = (M + M') / 2  symmetric       -> s(A,B) + s(B,A) = 2 x_A' S x_B
#   K = (M - M') / 2  antisymmetric   -> s(A,B) - s(B,A) = 2 x_A' K x_B
# r = |K| / |S| (Frobenius norms) measures how one-sided M is. For each r the
# program draws M, then 20,000 random pairs, and counts pairs where both
# scores are positive (mutual), where the signs differ (one-way), and where
# both are negative; and, in a pool of 200 people, how often A's best match
# "by what A gives" differs from A's best match "by what A receives".
import random

D, PAIRS, POOL = 6, 20000, 200

def rand_matrix(rng, r):
    a = [[rng.gauss(0, 1) for _ in range(D)] for _ in range(D)]
    s = [[(a[i][j] + a[j][i]) / 2 for j in range(D)] for i in range(D)]
    b = [[rng.gauss(0, 1) for _ in range(D)] for _ in range(D)]
    k = [[(b[i][j] - b[j][i]) / 2 for j in range(D)] for i in range(D)]
    ns = sum(v * v for row in s for v in row) ** 0.5
    nk = sum(v * v for row in k for v in row) ** 0.5
    return [[s[i][j] / ns + r * k[i][j] / nk for j in range(D)]
            for i in range(D)]

def score(m, x, y):
    return sum(x[i] * m[i][j] * y[j] for i in range(D) for j in range(D))

def person(rng):
    return [rng.uniform(-1, 1) for _ in range(D)]

if __name__ == "__main__":
    print("   r = |K|/|S|   mutual   one-way   both negative"
          "   top match differs")
    for r in (0.0, 0.5, 1.0, 2.0):
        rng = random.Random(62001)
        m = rand_matrix(rng, r)
        mu = one = neg = 0
        for _ in range(PAIRS):
            a, b = person(rng), person(rng)
            sab, sba = score(m, a, b), score(m, b, a)
            if sab > 0 and sba > 0:
                mu += 1
            elif sab < 0 and sba < 0:
                neg += 1
            else:
                one += 1
        pool = [person(rng) for _ in range(POOL)]
        diff = 0
        for i, a in enumerate(pool):
            others = [j for j in range(POOL) if j != i]
            give = max(others, key=lambda j: score(m, a, pool[j]))
            get = max(others, key=lambda j: score(m, pool[j], a))
            diff += give != get
        print("      {:3.1f}       {:6.3f}    {:6.3f}      {:6.3f}"
              "            {:5.3f}".format(r, mu / PAIRS, one / PAIRS,
                                          neg / PAIRS, diff / POOL))
    print("\nReading: with a symmetric M (r = 0) no pair is one-way. As the")
    print("antisymmetric part grows, more pairs have scores of opposite sign")
    print("and a person's best match depends on which direction is asked.")
#    r = |K|/|S|   mutual   one-way   both negative   top match differs
#       0.0        0.498     0.000       0.502            0.000
#       0.5        0.355     0.288       0.357            0.840
#       1.0        0.252     0.495       0.253            0.985
#       2.0        0.153     0.699       0.148            1.000
#
# Reading: with a symmetric M (r = 0) no pair is one-way. As the
# antisymmetric part grows, more pairs have scores of opposite sign
# and a person's best match depends on which direction is asked.

MM 对称时(r=0r = 0),没有一对是单向的,双向相容与双向相斥各占一半(0.498 与 0.502)。反对称部分一旦出现,单向的比例迅速上升:r=0.5r = 0.5 时为 0.288,r=1r = 1 时为 0.495,r=2r = 2 时为 0.699。更值得注意的是最后一列。即使 rr 只有 0.5,池子里也有 0.840 的人,其「最适合我给予的对象」与「最能给予我的对象」不是同一个人;r=1r = 1 时为 0.985。

这对任何「正缘匹配」功能都是一个直接的设计问题:如果评分矩阵不对称,「谁是你的最佳对象」这个问题本身就有两个答案,系统必须说明它回答的是哪一个。

什么样的数据看得见单向性

假设有人想用真实数据估计 MM。最容易收集的结局是两个人共有的:这段关系维持了多久,是否结婚,是否分手。第二段程序说明,这类数据原则上无法估计 KK。

推导

# Chapter 1. What symmetric outcomes can and cannot reveal about M.
# True M = S + K on d = 4 traits (16 numbers: 10 in S, 6 in K). N pairs
# (A, B) are observed. Two kinds of data:
#   (a) a SHARED outcome, the same number for both people (e.g. how long
#       the pair lasted): y = s(A,B) + s(B,A) + noise = 2 x_A' S x_B + noise
#   (b) TWO OWN outcomes, one per person: y_A = s(A,B) + noise and
#       y_B = s(B,A) + noise
# M is estimated by least squares on all 16 entries (normal equations solved
# by Gaussian elimination). The program reports the rank of the design, and
# the error of the estimated S and K.
import random

D = 4

def solve(a, b):
    n = len(b)
    m = [row[:] + [b[i]] for i, row in enumerate(a)]
    rank, piv_cols = 0, []
    for c in range(n):
        p = max(range(rank, n), key=lambda r: abs(m[r][c]))
        if abs(m[p][c]) < 1e-9:
            continue
        m[rank], m[p] = m[p], m[rank]
        for r in range(n):
            if r != rank:
                f = m[r][c] / m[rank][c]
                m[r] = [m[r][k] - f * m[rank][k] for k in range(n + 1)]
        piv_cols.append(c)
        rank += 1
    x = [0.0] * n
    for r, c in enumerate(piv_cols):
        x[c] = m[r][n] / m[r][c]
    return x, rank

def fit(rows, ys):
    n = D * D
    ata = [[sum(r[i] * r[j] for r in rows) for j in range(n)]
           for i in range(n)]
    aty = [sum(r[i] * y for r, y in zip(rows, ys)) for i in range(n)]
    return solve(ata, aty)

def feats(x, y):
    return [x[i] * y[j] for i in range(D) for j in range(D)]

def parts(v):
    m = [[v[i * D + j] for j in range(D)] for i in range(D)]
    s = [[(m[i][j] + m[j][i]) / 2 for j in range(D)] for i in range(D)]
    k = [[(m[i][j] - m[j][i]) / 2 for j in range(D)] for i in range(D)]
    return s, k

def err(a, b):
    num = sum((a[i][j] - b[i][j]) ** 2 for i in range(D) for j in range(D))
    den = sum(b[i][j] ** 2 for i in range(D) for j in range(D))
    return (num / den) ** 0.5

if __name__ == "__main__":
    rng = random.Random(62002)
    true = [rng.gauss(0, 1) for _ in range(D * D)]
    ts, tk = parts(true)
    tm = [[true[i * D + j] for j in range(D)] for i in range(D)]
    print("   pairs   data             rank of 16   error in S   error in K")
    for n in (200, 2000):
        rows_a, ys_a, rows_b, ys_b = [], [], [], []
        for _ in range(n):
            x = [rng.uniform(-1, 1) for _ in range(D)]
            y = [rng.uniform(-1, 1) for _ in range(D)]
            sxy = sum(x[i] * tm[i][j] * y[j]
                      for i in range(D) for j in range(D))
            syx = sum(y[i] * tm[i][j] * x[j]
                      for i in range(D) for j in range(D))
            fxy, fyx = feats(x, y), feats(y, x)
            rows_a.append([u + v for u, v in zip(fxy, fyx)])
            ys_a.append(sxy + syx + rng.gauss(0, 0.5))
            rows_b += [fxy, fyx]
            ys_b += [sxy + rng.gauss(0, 0.5), syx + rng.gauss(0, 0.5)]
        for label, rows, ys in (("shared outcome", rows_a, ys_a),
                                ("two own outcomes", rows_b, ys_b)):
            est, rank = fit(rows, ys)
            es, ek = parts(est)
            print("   {:5,d}   {:16s}   {:10d}   {:10.3f}   {:10.3f}".format(
                n, label, rank, err(es, ts), err(ek, tk)))
    print("\nReading: a shared outcome sees only x_A' S x_B. The six numbers")
    print("of K never enter it and the design has rank 10, so the K part of")
    print("the estimate is an arbitrary choice of the solver: every K fits")
    print("the data equally well, however many pairs are observed. Asymmetry")
    print("is visible only in outcomes measured separately for each person.")
#    pairs   data             rank of 16   error in S   error in K
#      200   shared outcome             10        0.055        1.968
#      200   two own outcomes           16        0.068        0.135
#    2,000   shared outcome             10        0.017        1.943
#    2,000   two own outcomes           16        0.017        0.045
#
# Reading: a shared outcome sees only x_A' S x_B. The six numbers
# of K never enter it and the design has rank 10, so the K part of
# the estimate is an arbitrary choice of the solver: every K fits
# the data equally well, however many pairs are observed. Asymmetry
# is visible only in outcomes measured separately for each person.

道理很简单。共有的结局是 s(A,B)+s(B,A)=2xA⊤SxBs(A,B) + s(B,A) = 2\, x_A^{\top} S x_B 加噪声,KK 根本不进入它。四个特征时 MM 有 16 个元素,其中对称部分 10 个、反对称部分 6 个;设计矩阵的秩只有 10。无论观察 200 对还是 2,000 对,SS 的估计误差都在缩小(0.055 降到 0.017),KK 的估计却只是解方程时的任意选择(误差 1.968 与 1.943),任何 KK 都同样好地拟合数据。只有当每个人的结局分别测量时——各自的满意度、各自的投入与收获——设计矩阵才是满秩的 16,KK 的误差才随样本缩小(0.135 降到 0.045)。

证据

伴侣研究中的同一结论。 伴侣与二人关系的统计学早已把这一点作为方法论的基本原则:同一对伴侣的两个结局要分别测量,并用「行动者—伴侣相互依赖模型」(APIM)同时估计每个人自身的效应与对方的效应;只有共有结局的数据无法区分两个方向的作用 (Kenny et al. 2006)。动力学模型也采用同样的写法:戈特曼等人把夫妻冲突中的每一方写成一个方程,各自有对对方的影响函数,两个影响函数可以不同 (Gottman et al. 2002);费尔姆利与格林伯格的二人互动模型同样为每个人单独设参数 (Felmlee and Greenberg 1999)。

从矩阵到张量

时间进入以后,评分可以随「流年」「流月」变化。最一般的写法是三阶张量:st(A,B)=∑i,j,kTijkxA,ixB,jck(t)s_t(A,B) = \sum_{i,j,k} T_{ijk}\, x_{A,i}\, x_{B,j}\, c_k(t),其中 c(t)c(t) 是时间的特征向量。对每一个时刻,TT 的切片仍是一个矩阵,上面的分解与结论逐片成立:只有共有结局的数据看不见每一片的反对称部分。时间维度没有带来新的可识别性,只带来更多需要估计的参数。

假说 · 尚未验证

作者的假说(尚未验证): 在分别测量伴侣双方满意度的纵向数据中,用任何一种固定的、预先公布的合盘编码构造 xx,估计出的反对称部分 KK 与零没有可区分的差别。什么结果会证明它错:在预先登记的分析中,KK 的估计在独立样本中可以重复,并且方向与编码的预先说明一致。

小结

把合盘评分写成双线性形式 xA⊤MxBx_A^{\top} M x_B 后,矩阵唯一地分成对称部分 SS(两人共有)与反对称部分 KK(单向流动)。反对称部分越大,符号相反的「单向」配对越多,而且一个人的「最佳对象」随所问的方向而不同:r=0.5r = 0.5 时已有 0.840 的人两个答案不同。只观察两人共有的结局,KK 不可识别——16 个参数中只有 10 个可以估计;要看见单向性,必须对每个人分别测量。三阶张量的时间推广不改变这一结论。

参考文献

Felmlee, Diane H., and David F. Greenberg. 1999. “A Dynamic Systems Model of Dyadic Interaction.” Journal of Mathematical Sociology 23 (3): 155–80.
Gottman, John M., James D. Murray, Catherine C. Swanson, Rebecca Tyson, and Kristin R. Swanson. 2002. The Mathematics of Marriage: Dynamic Nonlinear Models. MIT Press.
Kenny, David A., Deborah A. Kashy, and William L. Cook. 2006. Dyadic Data Analysis. Guilford Press.

Fan, Y. (2026). Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games: Asymmetric Kuramoto Locking, Stopping-Time Separation Hazards and Magic-Square Permutation Operators [双人相位耦合、双线性相容张量与时空网格博弈] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090172 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).