5D Library › 四柱排盘的历法计算与规则引擎 · English

第三章 出生时间误差与时辰边界

误差怎样变成换柱

出生时间很少精确到分钟。医院记录可能取整到五分钟或一刻钟,家人的回忆可能差半小时,经度与时区的换算又引入另一层误差。一个柱在边界处更换:时柱每 120 分钟一换,日柱每 1,440 分钟一换,月柱每过一个「节」一换(平均为回归年的十二分之一),年柱每过一个立春一换。若真实出生时间在时间轴上均匀分布,记录时间与真实时间相差 ee,则一个间隔为 LL 的柱被换错的概率是 E[min⁡(|e|,L)]/LE[\min(|e|, L)]/L。

推导

# Chapter 3. How often a timing error changes a pillar.
# A pillar changes at boundaries spaced L minutes apart (hour: 120; day:
# 1,440; month: one solar term "jie" to the next, on average a twelfth of
# a tropical year; year: one tropical year, at the Beginning of Spring).
# If the true birth time is spread evenly and the recorded time is off
# by e, the pillar is wrong with probability E[min(|e|, L)] / L. Two
# error models: e uniform on [-d, d], and e normal with s.d. d.
import math

YEAR = 365.2422 * 1440
L = {"hour": 120, "day": 1440, "month": YEAR / 12, "year": YEAR}

def mean_abs(d, model):
    return d / 2 if model == "uniform" else d * math.sqrt(2 / math.pi)

if __name__ == "__main__":
    for model in ("uniform", "normal"):
        print("   error {} with d = 5, 15, 30 minutes".format(model))
        print("     pillar      d=5       d=15      d=30")
        for k, span in L.items():
            print("     {:6s}  ".format(k) + "  ".join(
                "{:8.5f}".format(min(mean_abs(d, model), span) / span)
                for d in (5, 15, 30)))
    print("   one degree of longitude = 4 minutes of solar time")
    d = 30
    hour = mean_abs(d, "normal") / 120
    print("   normal error, s.d. 30 min: hour pillar wrong {:.3f}".format(
        hour))
    print("   boundary spacing in hours-of-two: " + ", ".join(
        "{} {:,.0f}".format(k, v / 120) for k, v in L.items()))
    print("\nReading: a quarter of an hour of uncertainty already changes")
    print("the hour pillar for one birth in ten under the normal model and")
    print("one in sixteen under the uniform; the day, month and year")
    print("pillars change far less often, because their boundaries are 12,")
    print("365 and 4,383 times as far apart.")
#    error uniform with d = 5, 15, 30 minutes
#      pillar      d=5       d=15      d=30
#      hour     0.02083   0.06250   0.12500
#      day      0.00174   0.00521   0.01042
#      month    0.00006   0.00017   0.00034
#      year     0.00000   0.00001   0.00003
#    error normal with d = 5, 15, 30 minutes
#      pillar      d=5       d=15      d=30
#      hour     0.03325   0.09974   0.19947
#      day      0.00277   0.00831   0.01662
#      month    0.00009   0.00027   0.00055
#      year     0.00001   0.00002   0.00005
#    one degree of longitude = 4 minutes of solar time
#    normal error, s.d. 30 min: hour pillar wrong 0.199
#    boundary spacing in hours-of-two: hour 1, day 12, month 365, year 4,383
#
# Reading: a quarter of an hour of uncertainty already changes
# the hour pillar for one birth in ten under the normal model and
# one in sixteen under the uniform; the day, month and year
# pillars change far less often, because their boundaries are 12,
# 365 and 4,383 times as far apart.

两种误差模型给出同样的图景。正负 5、15、30 分钟的均匀误差使时柱出错的概率为 0.02083、0.06250、0.12500;标准差为 5、15、30 分钟的正态误差为 0.03325、0.09974、0.19947。也就是说,一刻钟的不确定已经让大约十分之一(正态)或十六分之一(均匀)的人时柱有误。日柱、月柱、年柱的边界分别远 12 倍、365 倍、4,383 倍,所以同样的误差让它们出错的概率小一到三个数量级:标准差 30 分钟时,日柱为 0.01662,月柱为 0.00055。经度若取错一度,相当于 4 分钟的误差。

时辰边界校准

上面的数字是对所有出生时间的平均。对一个具体的用户,更有用的是条件概率:已知他报告的时间离时辰边界多远,时柱出错的机会有多大?若误差服从标准差为 ss 的正态分布,报告时间在时辰内第 tt 分钟,则出错概率为 P(t)=Φ(−t/s)+Φ(−(120−t)/s)P(t) = \Phi(-t/s) + \Phi(-(120 – t)/s),即越过前后两个边界之一的概率。

推导

# Chapter 3. The chance that the hour pillar is wrong, given the time.
# A user reports a birth time t minutes after the start of a 120-minute
# double-hour (in true solar time). If the true time differs from t by a
# normal error with s.d. s, the pillar is wrong with probability
#   P(t) = Phi(-t / s) + Phi(-(120 - t) / s)
# (the chance of crossing the earlier or the later boundary). This is
# the table a "boundary check" in reading software needs: it says how
# close to a boundary a reported time may be before a second chart
# should be shown.
import math

def phi(x):
    return 0.5 * (1 + math.erf(x / math.sqrt(2)))

def p_wrong(t, s):
    return phi(-t / s) + phi(-(120 - t) / s)

if __name__ == "__main__":
    ts = (0, 5, 10, 15, 20, 30, 45, 60)
    print("   minutes from slot start: " + "".join("{:>6d}".format(t)
                                               for t in ts))
    for s in (5, 15, 30):
        print("   s.d. {:2d} min             ".format(s) + "".join(
            "{:6.3f}".format(p_wrong(t, s)) for t in ts))
    print("   minutes from the nearest boundary for P < 0.05 and < 0.01:")
    def inside(s, level):
        return next((t / 10 for t in range(0, 601)
                     if p_wrong(t / 10, s) < level), None)
    for s in (5, 15, 30):
        safe5, safe1 = inside(s, 0.05), inside(s, 0.01)
        print("     s.d. {:2d}: {:5.1f} and {};  flagged at 0.05: {:.3f}"
              " of the slot".format(s, safe5, "never" if safe1 is None
                                    else "{:5.1f}".format(safe1),
                                    2 * safe5 / 120))
    print("\nReading: at the boundary itself the chance is one half for any")
    print("error size. With a quarter-hour error a time must lie about 25")
    print("minutes inside its double-hour before the chance falls below")
    print("0.05; with half an hour of error only the middle few minutes of")
    print("the slot get there, and no time reaches 0.01.")
#    minutes from slot start:      0     5    10    15    20    30    45    60
#    s.d.  5 min              0.500 0.159 0.023 0.001 0.000 0.000 0.000 0.000
#    s.d. 15 min              0.500 0.369 0.252 0.159 0.091 0.023 0.001 0.000
#    s.d. 30 min              0.500 0.434 0.370 0.309 0.253 0.160 0.073 0.046
#    minutes from the nearest boundary for P < 0.05 and < 0.01:
#      s.d.  5:   8.3 and  11.7;  flagged at 0.05: 0.138 of the slot
#      s.d. 15:  24.7 and  34.9;  flagged at 0.05: 0.412 of the slot
#      s.d. 30:  53.9 and never;  flagged at 0.05: 0.898 of the slot
#
# Reading: at the boundary itself the chance is one half for any
# error size. With a quarter-hour error a time must lie about 25
# minutes inside its double-hour before the chance falls below
# 0.05; with half an hour of error only the middle few minutes of
# the slot get there, and no time reaches 0.01.
时柱出错的条件概率随报告时间在时辰内位置的变化,三条曲线对应三种误差大小;虚线为 0.05。

在边界上,不论误差多大,出错的概率都是一半。误差标准差为 5 分钟时,离边界 8.3 分钟以上,概率就低于 0.05,只有 0.138 的时辰需要提示;标准差为 15 分钟时,要离边界 24.7 分钟,0.412 的时辰需要提示;标准差为 30 分钟时,要离边界 53.9 分钟,0.898 的时辰需要提示,而且没有任何位置能低于 0.01。

注

这张表可以直接作为软件的「时辰边界校准」。 软件可以请用户估计出生时间的可靠程度(精确到分钟、一刻钟、半小时),按上表判断报告时间是否落在提示区,落在提示区时同时显示相邻时辰的盘,而不是只给一张。这是关于不确定性的诚实报告,不涉及哪一张盘「准」。

节气边界与起运岁数

月柱以「节」为界。节是太阳视黄经到达 315 度(立春)、345 度(惊蛰)……的时刻,是天文计算。下面的程序用 Meeus 的低精度太阳理论计算 2026 年的十二个节 (Meeus 1998),并用香港天文台公布的 2026 年十二个中气时刻核对精度 (Hong Kong Observatory 2026)。

大运的起运岁数由出生时刻到下一个节(顺排)或上一个节(逆排)的天数除以 3 得出:三天折一岁。

推导

# Chapter 3. Solar-term boundaries and the starting age of luck cycles.
# Month pillars change at the twelve "jie" solar terms, when the Sun's
# apparent longitude reaches 315, 345, 15, ... degrees. The longitude is
# computed with the low-accuracy solar theory in Meeus, Astronomical
# Algorithms, ch. 25 (about 0.01 degree, i.e. about a quarter of an hour
# in time); Delta T = 69 s is assumed for 2026. Times are UTC+8. The
# method is checked against the twelve major terms of 2026 published by
# the Hong Kong Observatory (HKO), copied below as (longitude, month,
# day, hour, minute).
# Luck cycles start at an age of (days to the next jie, counting forward,
# or since the previous jie, counting backward) / 3 years.
import math

JIE = (("Li Chun", 315), ("Jing Zhe", 345), ("Qing Ming", 15),
       ("Li Xia", 45), ("Mang Zhong", 75), ("Xiao Shu", 105),
       ("Li Qiu", 135), ("Bai Lu", 165), ("Han Lu", 195),
       ("Li Dong", 225), ("Da Xue", 255), ("Xiao Han", 285))
DELTA_T = 69 / 86400
HKO_2026 = ((300, 1, 20, 9, 45), (330, 2, 18, 23, 52), (0, 3, 20, 22, 46),
            (30, 4, 20, 9, 39), (60, 5, 21, 8, 37), (90, 6, 21, 16, 25),
            (120, 7, 23, 3, 13), (150, 8, 23, 10, 19), (180, 9, 23, 8, 5),
            (210, 10, 23, 17, 38), (240, 11, 22, 15, 23),
            (270, 12, 22, 4, 50))

def sun_longitude(jde):
    t = (jde - 2451545.0) / 36525
    l0 = 280.46646 + 36000.76983 * t + 0.0003032 * t * t
    m = math.radians(357.52911 + 35999.05029 * t - 0.0001537 * t * t)
    c = ((1.914602 - 0.004817 * t - 0.000014 * t * t) * math.sin(m)
         + (0.019993 - 0.000101 * t) * math.sin(2 * m)
         + 0.000289 * math.sin(3 * m))
    om = math.radians(125.04 - 1934.136 * t)
    return (l0 + c - 0.00569 - 0.00478 * math.sin(om)) % 360

def crossing(target, jd_guess):
    jd = jd_guess
    for _ in range(50):
        diff = (target - sun_longitude(jd) + 180) % 360 - 180
        jd += diff / 0.9856
        if abs(diff) < 1e-7:
            break
    return jd - DELTA_T + 8 / 24          # UTC+8, as a Julian date

def calendar(jd):
    z, f = int(jd + 0.5), jd + 0.5 - int(jd + 0.5)
    a = z + 32044
    b = (4 * a + 3) // 146097
    c = a - 146097 * b // 4
    d = (4 * c + 3) // 1461
    e = c - 1461 * d // 4
    m = (5 * e + 2) // 153
    day = e - (153 * m + 2) // 5 + 1
    month = m + 3 - 12 * (m // 10)
    year = 100 * b + d - 4800 + m // 10
    mins = round(f * 1440)
    return year, month, day, mins // 60, mins % 60

if __name__ == "__main__":
    start = 2461070.5                     # 1 February 2026, 0h UT
    times = []
    for k, (name, lon) in enumerate(JIE):
        times.append(crossing(lon, start + 30.44 * k + 3))
    errs = []
    for k, (lon, mo, d, h, mi) in enumerate(HKO_2026):
        y, mo2, d2, h2, mi2 = calendar(crossing(lon, 2461059.5 + 30.44 * k))
        errs.append((d2 - d) * 1440 + (h2 - h) * 60 + (mi2 - mi))
    print("   major terms of 2026, computed minus HKO: {:+d} to {:+d} minutes"
          .format(min(errs), max(errs)))
    print("   jie solar terms of 2026 (UTC+8):")
    for (name, _), jd in zip(JIE, times):
        y, mo, d, h, mi = calendar(jd)
        print("     {:10s} {}-{:02d}-{:02d} {:02d}:{:02d}".format(
            name, y, mo, d, h, mi))
    gaps = [b - a for a, b in zip(times, times[1:])]
    print("   gaps between jie: {:.2f} to {:.2f} days".format(min(gaps),
                                                         max(gaps)))
    print("   largest starting age: {:.2f} years".format(max(gaps) / 3))
    print("   a 30-minute timing error moves the starting age by {:.4f}"
          " years".format(30 / 1440 / 3))
    print("   = {:.1f} days; a birth one minute either side of a jie moves"
          .format(30 / 1440 / 3 * 365.25))
    print("   it by up to {:.2f} years".format(max(gaps) / 3))
    print("\nReading: between solar terms the starting age is a straight")
    print("line, one year for every three days, so ordinary timing errors")
    print("barely move it; at each jie it jumps by up to ten years, and")
    print("there a quarter-hour error in the term or the birth decides it.")
#    major terms of 2026, computed minus HKO: -10 to +4 minutes
#    jie solar terms of 2026 (UTC+8):
#      Li Chun    2026-02-04 03:55
#      Jing Zhe   2026-03-05 21:49
#      Qing Ming  2026-04-05 02:27
#      Li Xia     2026-05-05 19:35
#      Mang Zhong 2026-06-05 23:36
#      Xiao Shu   2026-07-07 09:49
#      Li Qiu     2026-08-07 19:39
#      Bai Lu     2026-09-07 22:41
#      Han Lu     2026-10-08 14:29
#      Li Dong    2026-11-07 17:50
#      Da Xue     2026-12-07 10:49
#      Xiao Han   2027-01-05 22:05
#    gaps between jie: 29.47 to 31.43 days
#    largest starting age: 10.48 years
#    a 30-minute timing error moves the starting age by 0.0069 years
#    = 2.5 days; a birth one minute either side of a jie moves
#    it by up to 10.48 years
#
# Reading: between solar terms the starting age is a straight
# line, one year for every three days, so ordinary timing errors
# barely move it; at each jie it jumps by up to ten years, and
# there a quarter-hour error in the term or the birth decides it.
2026 年按顺排计算的起运岁数随出生时刻的变化:节与节之间是直线,在每个节处跳变。

与香港天文台的中气时刻相比,程序的计算偏差在 −10 到 +4 分钟之间,所以上面列出的节时刻约有十分钟的不确定,用于排盘应以天文台历书为准。节与节相隔 29.47 到 31.43 天,所以起运岁数最大为 10.48 岁。

起运岁数是出生时刻的分段线性函数:在两个节之间,每晚三天少一岁,30 分钟的误差只把起运岁数移动 0.0069 年,约 2.5 天,可以忽略。但在每个节处,函数跳变:出生在节前一分钟与节后一分钟,顺排的起运岁数相差可达 10.48 年。在这里,十分钟的节气时刻误差或出生时间误差,决定的不是几天,而是十年。

小结

时间误差几乎只影响时柱:一刻钟的误差让十分之一左右的人时柱有误,日柱、月柱、年柱的风险小一到三个数量级。条件概率 P(t)P(t) 给出「时辰边界校准」的依据:误差标准差为 15 分钟时,离边界不到约 25 分钟的报告时间应当提示。起运岁数在节与节之间是平缓的直线,在节处跳变可达 10.48 年;节时刻本身需要以天文台历书核对。

参考文献

Hong Kong Observatory. 2026. The 24 Solar Terms in 2026. https://www.hko.gov.hk/tc/gts/astron2026/files/2026SolarTerms24.pdf.
Meeus, Jean. 1998. Astronomical Algorithms. 2nd ed. Willmann-Bell.

Fan, Y. (2026). Four-Pillar Calendrical Computation and Formal Rule Engines: Julian-Day Sexagenary Cycles, Midnight-Boundary Disagreements, Birth-Time Sensitivity Bounds and Weighted-Graph Strength Scoring [四柱排盘的历法计算与规则引擎] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090180 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).