关于「旺衰是加权图上的打分」,《四柱排盘的计算》给出的定量结论是什么?

结论:第五章把旺衰判断写成加权图上的打分,三套说得通的参数对全部四柱两两的 Cohen's kappa 只有 0.553 到 0.622,三者一致的盘占 0.684,从格的比例在 0.022 与 0.121 之间;时支差一格,判定对 0.127 的盘改变。

数据口径:书中以标注框区分已发表的证据、可运行的 Python 计算(16 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 与结论吻合的打印值: 0.022, 0.121, 0.553, 0.622, 0.684

   518,400 charts; share strong / weak / follow:
     A: 0.334 / 0.544 / 0.121
     B: 0.235 / 0.728 / 0.037
     C: 0.391 / 0.587 / 0.022
   A vs B: agreement 0.768, Cohen's kappa 0.553
   A vs C: agreement 0.781, Cohen's kappa 0.600
   B vs C: agreement 0.819, Cohen's kappa 0.622
   all three agree on 0.684 of charts
Reading: all three conventions agree on about two charts in
three; kappa between 0.55 and 0.62 is only moderate agreement.
The share of 'follow' charts ranges from 0.022 to 0.121: whether
a chart follows is decided mostly by the convention.
查看完整验算程序
# Chapter 5. A strength-scoring engine and three conventions.
# Every chart (60 year pillars x 12 months x 60 day pillars x 12 hours)
# is scored from the day stem's point of view. Each of the seven other
# positions contributes an element vector (stems: their own element;
# branches: hidden stems weighted as in p09), times a position weight.
# Support = same element + w_res x the element that generates the day
# element; drain = the three other relations, with weights. With
# r = support / (support + drain):
#   strong if r >= tau; "follow" if r < phi and the day element has no
#   root in any branch; otherwise weak.
# A, B and C are three invented but defensible parameter sets, not the
# rules of any named school.
HIDDEN = ((9,), (5, 9, 7), (0, 2, 4), (1,), (4, 1, 9), (2, 4, 6), (3, 5),
          (5, 3, 1), (6, 8, 4), (7,), (4, 7, 3), (8, 0))
DAYS = (((8, 10), (9, 20)), ((9, 9), (7, 3), (5, 18)),
        ((4, 7), (2, 7), (0, 16)), ((0, 10), (1, 20)),
        ((1, 9), (9, 3), (4, 18)), ((4, 5), (6, 9), (2, 16)),
        ((2, 10), (5, 9), (3, 11)), ((3, 9), (1, 3), (5, 18)),
        ((4, 10), (8, 3), (6, 17)), ((6, 10), (7, 20)),
        ((7, 9), (3, 3), (4, 18)), ((4, 7), (0, 5), (8, 18)))
SCHOOLS = {   # hidden, month w, day-branch w, w_res, drains, tau, phi
    "A": ("S1", 3.0, 1.5, 1.0, (1.0, 1.0, 1.0), 0.50, 0.20),
    "B": ("S2", 2.5, 1.2, 0.8, (0.8, 1.0, 1.2), 0.50, 0.20),
    "C": ("S3", 4.0, 1.0, 1.0, (1.0, 1.0, 1.0), 0.45, 0.15)}

def branch_vec(b, scheme):
    v, h = [0.0] * 5, HIDDEN[b]
    if scheme == "S1":
        pairs = [(h[0], 1.0)]
    elif scheme == "S2":
        pairs = zip(h, {1: (1.0,), 2: (0.7, 0.3), 3: (0.6, 0.3, 0.1)}[len(h)])
    else:
        pairs = [(s, d / 30) for s, d in DAYS[b]]
    for s, w in pairs:
        v[s // 2] += w
    return v

def stem_vec(s):
    v = [0.0] * 5
    v[s // 2] = 1.0
    return v

def classify_all(p):
    scheme, mw, dw, wres, drains, tau, phi = p
    bv = [branch_vec(b, scheme) for b in range(12)]
    year, day = [], []
    for y in range(60):
        ys, yb = y % 10, y % 12
        for mb in range(12):
            ms = (2 * (ys % 5) + 2 + (mb - 2) % 12) % 10
            v = [a + c + d + mw * e for a, c, d, e in zip(
                stem_vec(ys), bv[yb], stem_vec(ms), bv[mb])]
            roots = {e for e in range(5) if bv[yb][e] or bv[mb][e]}
            year.append((v, roots))
    for dd in range(60):
        ds, db = dd % 10, dd % 12
        for hb in range(12):
            hs = (2 * (ds % 5) + hb) % 10
            v = [dw * a + c + d for a, c, d in zip(bv[db], stem_vec(hs),
                                                    bv[hb])]
            roots = {e for e in range(5) if bv[db][e] or bv[hb][e]}
            day.append((ds // 2, v, roots))
    out = []
    for yv, yr in year:
        for de, dv, dr in day:
            v = [a + b for a, b in zip(yv, dv)]
            sup = v[de] + wres * v[(de - 1) % 5]
            dra = (drains[0] * v[(de + 1) % 5] + drains[1] * v[(de + 2) % 5]
                   + drains[2] * v[(de + 3) % 5])
            r = sup / (sup + dra)
            if r >= tau:
                out.append(0)
            elif r < phi and de not in yr and de not in dr:
                out.append(2)
            else:
                out.append(1)
    return out

def kappa(a, b, k=3):
    n = len(a)
    conf = [[0] * k for _ in range(k)]
    for x, y in zip(a, b):
        conf[x][y] += 1
    po = sum(conf[i][i] for i in range(k)) / n
    pe = sum(sum(conf[i]) * sum(r[i] for r in conf) for i in range(k)) / n / n
    return po, (po - pe) / (1 - pe)

if __name__ == "__main__":
    cls = {s: classify_all(p) for s, p in SCHOOLS.items()}
    n = len(cls["A"])
    print("   {:,d} charts; share strong / weak / follow:".format(n))
    for s, c in cls.items():
        print("     {}: {:.3f} / {:.3f} / {:.3f}".format(
            s, c.count(0) / n, c.count(1) / n, c.count(2) / n))
    for a, b in (("A", "B"), ("A", "C"), ("B", "C")):
        po, k = kappa(cls[a], cls[b])
        print("   {} vs {}: agreement {:.3f}, Cohen's kappa {:.3f}".format(
            a, b, po, k))
    allsame = sum(x == y == z for x, y, z in zip(*cls.values())) / n
    print("   all three agree on {:.3f} of charts".format(allsame))
    print("\nReading: all three conventions agree on about two charts in")
    print("three; kappa between 0.55 and 0.62 is only moderate agreement.")
    print("The share of 'follow' charts ranges from 0.022 to 0.121: whether")
    print("a chart follows is decided mostly by the convention.")

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《四柱排盘的历法计算与规则引擎》第 5 章「旺衰是加权图上的打分」(版本 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090180

DOI: 10.5281/zenodo.24090180 · 阅读本章所在专著 · 5DL-B-066 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026066,
  author    = {Fan, Yafu},
  title     = {Four-Pillar Calendrical Computation and Formal Rule Engines},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  doi       = {10.5281/zenodo.24090180},
  url       = {https://doi.org/10.5281/zenodo.24090180}
}

本书其他章节结论