5D Library › Four-Pillar Calendrical Computation and Formal Rule Engines · 中文

Chapter 3. Timing Errors and the Edges of the Double-Hours

How an error becomes a changed pillar

Birth times are seldom exact to the minute. Hospital records may be rounded to five minutes or a quarter of an hour, family memory may be half an hour out, and longitude and time-zone conversion add another layer of error. A pillar changes at its boundaries: the hour pillar every 120 minutes, the day pillar every 1,440 minutes, the month pillar at each “jie” solar term (on average a twelfth of a tropical year), and the year pillar at each Beginning of Spring. If the true time of birth is spread evenly along the time axis and the recorded time differs from it by ee, a pillar whose boundaries are LL apart is wrong with probability E[min⁡(|e|,L)]/LE[\min(|e|, L)]/L.

Calculation

# 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.

The two error models tell the same story. A uniform error of up to 5, 15 or 30 minutes either way makes the hour pillar wrong with probability 0.02083, 0.06250 or 0.12500; a normal error with standard deviation 5, 15 or 30 minutes with 0.03325, 0.09974 or 0.19947. A quarter of an hour of uncertainty, then, already gives about one person in ten (normal) or one in sixteen (uniform) a wrong hour pillar. The boundaries of the day, month and year pillars are 12, 365 and 4,383 times as far apart, so the same error makes them wrong one to three orders of magnitude less often: with a standard deviation of 30 minutes, 0.01662 for the day pillar and 0.00055 for the month pillar. A longitude wrong by one degree amounts to an error of 4 minutes.

A boundary check for the double-hours

The figures above are averages over all birth times. For a particular user the conditional probability is more useful: given how far the reported time lies from the edge of its double-hour, how likely is the hour pillar to be wrong? If the error is normal with standard deviation ss and the reported time lies tt minutes into the double-hour, the probability is P(t)=Φ(−t/s)+Φ(−(120−t)/s)P(t) = \Phi(-t/s) + \Phi(-(120 – t)/s), the chance of crossing one of the two edges.

Calculation

# 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.
Conditional probability of a wrong hour pillar against the position of the reported time within the double-hour, for three error sizes; the dashed line is 0.05.

At an edge the probability is one half whatever the size of the error. With a standard deviation of 5 minutes, a time more than 8.3 minutes from the edge is below 0.05, and only 0.138 of the double-hour needs a flag; with 15 minutes, 24.7 minutes from the edge, and 0.412 of the double-hour needs a flag; with 30 minutes, 53.9 minutes, 0.898 of the double-hour needs a flag, and no position at all gets below 0.01.

Note

This table can serve directly as a program’s “boundary check”. A program can ask the user how reliable the birth time is (to the minute, the quarter-hour, the half-hour), use the table to see whether the reported time falls in the flagged zone, and in that case show the chart of the neighbouring double-hour as well, instead of only one chart. This is honest reporting of uncertainty and says nothing about which chart is “right”.

Solar-term boundaries and the starting age of the luck cycles

Month pillars change at the “jie” terms, the moments when the Sun’s apparent longitude reaches 315 degrees (Beginning of Spring), 345 degrees (Awakening of Insects) and so on, an astronomical calculation. The next program computes the twelve jie of 2026 with Meeus’s low-accuracy solar theory (Meeus 1998) and checks its accuracy against the twelve major terms of 2026 published by the Hong Kong Observatory (Hong Kong Observatory 2026).

The starting age of the luck cycles is the number of days from birth to the next jie (counting forward) or back to the previous jie (counting backward), divided by 3: three days count as one year.

Calculation

# 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.
The starting age, counting forward, against the moment of birth in 2026: a straight line between terms, with a jump at each term.

Against the Hong Kong Observatory’s major terms the program is off by −10 to +4 minutes, so the jie times listed above are uncertain by about ten minutes, and charts should take their terms from an observatory almanac. Successive jie are 29.47 to 31.43 days apart, so the starting age is at most 10.48 years.

The starting age is a piecewise linear function of the moment of birth: between two terms it drops by one year for every three days, and a 30-minute error moves it by only 0.0069 years, about 2.5 days, which is negligible. At each term the function jumps: births one minute before and one minute after a term can differ in forward starting age by as much as 10.48 years. Here an error of ten minutes in the term or in the birth time decides not a few days but ten years.

Summary

Timing errors affect almost only the hour pillar: a quarter of an hour of error gives about one person in ten a wrong hour pillar, while the risks for the day, month and year pillars are one to three orders of magnitude smaller. The conditional probability P(t)P(t) is the basis of a “boundary check”: with a standard deviation of 15 minutes, reported times less than about 25 minutes from an edge should be flagged. The starting age of the luck cycles is a gentle straight line between terms and jumps by as much as 10.48 years at a term; the term times themselves should be checked against an observatory almanac.

References

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).