关于「分支概率与信息:历法抽样、互信息与均匀权重」,《大六壬的群作用与九宗门代数》给出的定量结论是什么?

结论:第六章用 2026 年的真实历法检验均匀权重,并算出法门熵中由步长决定的份额为 0.434。

数据口径:书中关于用户、档案与价格的参数均为示意;全部计算由书中程序生成;本书分析体系的结构与概率,不做任何个人占断,也不是法律、财务或经营建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(19 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 2026

2026-01-01 is day 11 of the cycle
all 12 hours4380 situations
gates chi20.08, df 8, p = 1.000
shifts chi20.00, df 11, p = 1.000
largest gap: zeike 0.4692 seen vs 0.4681 exact
mao to you only2555 situations
gates chi20.71, df 8, p = 1.000
shifts chi20.48, df 11, p = 1.000
largest gap: biyong 0.1100 seen vs 0.1125 exact
查看完整验算程序
# Chapter 6. p61: Exact enumeration versus a real calendar year. We walk
# every civil day of 2026 and all 12 double hours, take the day's
# stem-branch from the anchor 1949-10-01 = jia-zi, and the monthly
# general from approximate mid-month solar-term dates (illustrative,
# +-1 day). Gate shares are compared with the exact shares of p31 by a
# chi-square statistic; then the same for day-time hours (mao to you).
# The calendar is not a random sample, so p is a yardstick, not a test
# at the usual 0.05 level.
import datetime as dt
import math
from collections import Counter

B = ("zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen",
     "you", "xu", "hai")
G = ("jia", "yi", "bing", "ding", "wu", "ji", "geng", "xin", "ren", "gui")
BE = (4, 2, 0, 0, 2, 1, 1, 2, 3, 3, 2, 4)  # 0 wood 1 fire 2 earth
GE = (0, 0, 1, 1, 2, 2, 3, 3, 4, 4)        # 3 metal 4 water
GONG = (2, 4, 5, 7, 5, 7, 8, 10, 11, 1)    # lodging palace of each stem
XING = (3, 10, 5, 0, 4, 8, 6, 1, 2, 9, 7, 11)   # punishment map


def ke(a, b):
    """True if element a overcomes element b."""
    return (b - a) % 5 == 2


def uniq(xs):
    out = []
    for x in xs:
        if x not in out:
            out.append(x)
    return out


def depth(u, s, kind, cnt="A", home=True):
    """She-hai depth of upper u walking home from ground (u - s)."""
    n = 0
    for i in range(s + 1 if home else s):
        q = (u - s + i) % 12
        for e in [BE[q]] + [GE[g] for g in range(10) if GONG[g] == q]:
            if cnt == "B" and kind == "ke":
                n += ke(BE[u], e)
            else:
                n += ke(e, BE[u])
    return n


def pick(pool, k, s, kind, v):
    g = k % 10
    if len(pool) == 1:
        return pool[0], "one"
    bi = [u for u in pool if u % 2 == g % 2]
    if len(bi) == 1:
        return bi[0], "biyong"
    pool = bi or pool
    tied = pool
    if v.get("mode", "depth") == "depth":
        ds = [depth(u, s, kind, v.get("cnt", "A"), v.get("home", True))
              for u in pool]
        tied = [u for u, d in zip(pool, ds) if d == max(ds)]
        if len(tied) == 1:
            return tied[0], "depth"
    for lab, r in (("jianji", 2), ("chawei", 0)):
        on = [u for u in tied if (u - s) % 12 % 3 == r]
        if len(on) == 1:
            return on[0], lab
        if on:
            break
    z = GONG[g] if g % 2 == 0 else k % 12
    return (z + s) % 12, "zhuixia"


def lessons(k, s):
    a = (GONG[k % 10] + s) % 12
    c = (k % 12 + s) % 12
    return a, (a + s) % 12, c, (c + s) % 12


def sanchuan(k, s, v=None):
    """(initial, middle, final, gate, how) for day k and shift s."""
    v = v or {}
    g, z = k % 10, k % 12
    yang = g % 2 == 0
    a, b, c, d = lessons(k, s)
    low = ((a, GE[g]), (b, BE[a]), (c, BE[z]), (d, BE[c]))
    zei = uniq([u for u, e in low if ke(e, BE[u])])
    kk = uniq([u for u, e in low if ke(BE[u], e)])
    if s == 0:
        gan = bool(zei or kk) or yang
        x = a if gan else c
        y = (c if gan else a) if XING[x] == x else XING[x]
        w = (y + 6) % 12 if XING[y] == y else XING[y]
        how = "withke" if zei or kk else ("yangday" if yang else "yinday")
        return x, y, w, "fuyin", how
    if zei or kk:
        x, how = pick(zei or kk, k, s, "zei" if zei else "ke", v)
        if how == "one":
            how = "chongshen" if zei else "yuanshou"
        gate = {"chongshen": "zeike", "yuanshou": "zeike",
                "biyong": "biyong"}.get(how, "shehai")
        if s == 6:
            gate = "fanyin"
        return x, (x + s) % 12, (x + 2 * s) % 12, gate, how
    if s == 6:
        sheng = [t % 12 for t in (z, z + 4, z + 8) if t % 3 == 2][0]
        return (sheng + 6) % 12, c, a, "fanyin", "jinglan"
    ups = uniq([b, c, d])
    p1 = [u for u in ups if ke(BE[u], GE[g])]
    p2 = [u for u in ups if ke(GE[g], BE[u])]
    same = GONG[g] == z
    if (p1 or p2) and not (same and v.get("bz_first")):
        x, _ = pick(p1 or p2, k, s, "ke", v)
        how = "haoshi" if p1 else "danshe"
        return x, (x + s) % 12, (x + 2 * s) % 12, "yaoke", how
    if same:
        x = (a + 2) % 12 if yang else (d - 2) % 12
        return x, a, a, "bazhuan", "bazhuan"
    if len({(a, GONG[g]), (b, a), (c, z), (d, c)}) < 4:
        x = (GONG[(g + 5) % 10] + s) % 12 if yang else (z + 4) % 12
        return x, a, a, "bieze", "bieze"
    if yang:
        return (9 + s) % 12, c, a, "maoxing", "mao-yang"
    return (9 - s) % 12, a, c, "maoxing", "mao-yin"

# (month, day) on which a general takes over, and its branch (2026)
TERMS = ((1, 20, 0), (2, 18, 11), (3, 20, 10), (4, 20, 9), (5, 21, 8),
         (6, 21, 7), (7, 23, 6), (8, 23, 5), (9, 23, 4), (10, 23, 3),
         (11, 22, 2), (12, 22, 1))


def general(d):
    j = 1                                  # chou since winter solstice
    for m, dd, b in TERMS:
        if (d.month, d.day) >= (m, dd):
            j = b
    return j


def chi_sf(x, df):
    """upper tail of chi-square via the regularised gamma series"""
    if x <= 0:
        return 1.0
    a, t = df / 2, x / 2
    terms = [1.0 / a]
    while terms[-1] > 1e-16 * terms[0]:
        terms.append(terms[-1] * t / (a + len(terms)))
    lead = math.exp(-t + a * math.log(t) - math.lgamma(a))
    return 1 - lead * math.fsum(terms)


exact = Counter(sanchuan(k, s)[3] for k in range(60) for s in range(12))
d0, anchor = dt.date(2026, 1, 1), dt.date(1949, 10, 1)
print("2026-01-01 is day", (d0 - anchor).days % 60, "of the cycle")
for label, hours in (("all 12 hours", range(12)),
                     ("mao to you only", range(3, 10))):
    seen, shifts = Counter(), Counter()
    for i in range(365):
        d = d0 + dt.timedelta(days=i)
        k = (d - anchor).days % 60
        for h in hours:
            s = (general(d) - h) % 12
            seen[sanchuan(k, s)[3]] += 1
            shifts[s] += 1
    n = math.fsum(seen.values())
    chi = math.fsum((seen[g] - n * exact[g] / 720) ** 2
                    / (n * exact[g] / 720) for g in exact)
    chs = math.fsum((shifts[s] - n / 12) ** 2 / (n / 12)
                    for s in range(12))
    print("{}: {} situations".format(label, int(n)))
    print("  gates  chi2 = {:.2f}, df 8, p = {:.3f}".format(
        chi, chi_sf(chi, 8)))
    print("  shifts chi2 = {:.2f}, df 11, p = {:.3f}".format(
        chs, chi_sf(chs, 11)))
    print("  largest gap: {} {:.4f} seen vs {:.4f} exact".format(
        *max(((g, seen[g] / n, exact[g] / 720) for g in exact),
             key=lambda t: abs(t[1] - t[2]))))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《大六壬天地盘置换、四课三传有向图与九宗门涉害深度代数》第 6 章「分支概率与信息:历法抽样、互信息与均匀权重」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-153 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026153,
  author    = {Fan, Yafu},
  title     = {Da Liu Ren Heaven-Earth Plate Permutations, Four-Lesson Three-Transmission Digraphs and the Depth Algebra of the Nine Methods},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论