5D Library › Almanac Auspicious Boolean Lattices, Jianchu Twelve-Officer Congruences and Runic Combinatorics · 中文
Chapter 8. Auditing an Almanac App and a Pre-Registered Test
Common slips, counted
An almanac or rune app can be checked against the rules it claims to follow. Four slips are common: cycling the officers without the repeat days, changing the year on 1 January, changing it at the lunar new year rather than at Lichun (the almanac year of the stem-branch system begins at Lichun), and computing the solar terms in the wrong time zone.
Calculation
# Chapter 8. p15: Auditing an almanac app against the rules. For 2027,
# the number of days on which a common slip changes the officer or the
# year-breaker mark, against a correct Beijing-time computation:
# (a) a plain 12-day officer cycle with no repeat days; (b) the year
# branch changed on 1 January instead of at Lichun (4 February); (c) the
# year branch changed at the lunar new year (6 February 2027); (d) the
# jie computed for UTC-8 instead of Beijing time.
import datetime
OFFICERS = ("jian chu man ping ding zhi po wei cheng shou kai bi").split()
# the 12 "jie" of 2027, Beijing time (UTC+8), from NAOJ's 2027 table
JIE = ((1, 5, 22, 10), (2, 4, 9, 46), (3, 6, 3, 40), (4, 5, 8, 17),
(5, 6, 1, 25), (6, 6, 5, 26), (7, 7, 15, 37), (8, 8, 1, 27),
(9, 8, 4, 28), (10, 8, 20, 17), (11, 7, 23, 39), (12, 7, 16, 38))
D0 = datetime.date(2027, 1, 1) # geng-chen day, mansion Gui (22)
def days(offset_h=0):
"""One dict per day of 2027: stem, branch, month and year branch."""
jie = [datetime.datetime(2027, m, d, h, mi) +
datetime.timedelta(hours=offset_h) for m, d, h, mi in JIE]
out = []
for k in range(365):
day = D0 + datetime.timedelta(days=k)
n = sum(1 for j in jie if j.date() <= day) # jie passed
gz = (16 + k) % 60
out.append({"date": day, "gz": gz, "s": gz % 10, "b": gz % 12,
"M": n % 12, "Y": 6 if n < 2 else 7,
"mansion": (22 + k) % 28})
return out
def officer(d):
return (d["b"] - d["M"]) % 12
def breaker(d, Y):
return d["b"] == (Y + 6) % 12
if __name__ == "__main__":
ds = days()
off = [officer(d) for d in ds]
plain = [(off[0] + k) % 12 for k in range(365)]
print(" (a) no repeat days: officer wrong on {} days".format(
sum(1 for x, y in zip(plain, off) if x != y)))
jan = sum(1 for d in ds if breaker(d, d["Y"]) != breaker(d, 7))
moved = sum(1 for d in ds if d["Y"] != 7)
print(" (b) year from 1 January: {} days in the wrong year, year"
.format(moved))
print(" breaker wrong on {} days".format(jan))
cny = datetime.date(2027, 2, 6)
lny = sum(1 for d in ds if breaker(d, d["Y"]) !=
breaker(d, 6 if d["date"] < cny else 7))
moved = sum(1 for d in ds if d["Y"] != (6 if d["date"] < cny else 7))
print(" (c) year from lunar new year: {} days in the wrong year,"
.format(moved))
print(" year breaker wrong on {} days".format(lny))
west = [officer(d) for d in days(-16)]
print(" (d) UTC-8 jie: officer wrong on {} days".format(
sum(1 for x, y in zip(west, off) if x != y)))
# (a) no repeat days: officer wrong on 336 days
# (b) year from 1 January: 34 days in the wrong year, year
# breaker wrong on 6 days
# (c) year from lunar new year: 2 days in the wrong year,
# year breaker wrong on 0 days
# (d) UTC-8 jie: officer wrong on 8 daysIn 2027, the plain cycle is wrong on 336 days. Changing the year on 1 January puts 34 days in the wrong year and gets the year breaker wrong on 6 of them. Changing it at the lunar new year (6 February 2027) puts 2 days in the wrong year, harmless for the year breaker in 2027 but not in every year. Computing the terms for UTC-8 gets the officer wrong on 8 days.
What a test of the almanac would need
Calculation
# Chapter 8. p16: What it would take to test an almanac claim, and a
# rune set. (1) Do small businesses opened on an almanac "good" day
# survive two years more often? Base survival 0.70; sample size per arm
# to detect +5 or +10 points (two-sided alpha 0.05, power 0.80). (2) With
# 10 almanac schools tested at alpha 0.05 each, the chance that at least
# one "works" by luck. (3) Is a rune bag fair? Each draw is one single
# rune taken at random from the full bag, its orientation recorded, and
# the rune returned before the next draw (independent draws with
# replacement). Draws needed to tell a reversal share of 0.36 from the
# exact 0.3125. Both sample sizes use the same two-sided test: alpha 0.05
# split over two tails, quantile z(1 - alpha/2), power 0.80.
import math
from statistics import NormalDist
Z = NormalDist().inv_cdf
def n_two(p1, p2, alpha=0.05, power=0.80):
pb = (p1 + p2) / 2
num = (Z(1 - alpha / 2) * math.sqrt(2 * pb * (1 - pb)) +
Z(power) * math.sqrt(p1 * (1 - p1) + p2 * (1 - p2)))
return math.ceil(num ** 2 / (p1 - p2) ** 2)
def n_one(p0, p1, alpha=0.05, power=0.80):
# one-sample test of a proportion, two-sided like n_two above
num = (Z(1 - alpha / 2) * math.sqrt(p0 * (1 - p0)) +
Z(power) * math.sqrt(p1 * (1 - p1)))
return math.ceil(num ** 2 / (p1 - p0) ** 2)
if __name__ == "__main__":
for lift in (0.05, 0.10):
print(" survival 0.70 -> {:.2f}: {:,} businesses per arm".format(
0.70 + lift, n_two(0.70, 0.70 + lift)))
print(" 10 schools, at least one false positive: {:.3f}".format(
1 - 0.95 ** 10))
print(" with Bonferroni (alpha 0.005 each): {:.3f}".format(
1 - 0.995 ** 10))
print(" rune bag, single runes drawn with replacement,")
print(" reversal share 0.3125 vs 0.36 (two-sided): {:,} draws".format(
n_one(0.3125, 0.36)))
# survival 0.70 -> 0.75: 1,251 businesses per arm
# survival 0.70 -> 0.80: 294 businesses per arm
# 10 schools, at least one false positive: 0.401
# with Bonferroni (alpha 0.005 each): 0.049
# rune bag, single runes drawn with replacement,
# reversal share 0.3125 vs 0.36 (two-sided): 764 drawsTo test whether small businesses opened on almanac-good days survive two years more often, with a base survival of 0.70, detecting a rise to 0.75 needs 1,251 businesses per arm and a rise to 0.80 needs 294. Testing 10 schools at the usual level gives at least one false “success” with probability 0.401; with the Bonferroni correction, 0.049. A rune bag can be tested too: telling a reversal share of 0.36 from the exact 0.3125 needs 764 recorded draws. Each of these draws is a single rune taken at random from the full bag, its orientation recorded, and the rune returned before the next draw, so the draws are independent and with replacement; the test is two-sided, like the business comparison, at level 0.05 with power 0.80.
Note
A four-step check for almanac and rune apps. First, recompute the officers from the stem-branch and the solar terms for your own place, and check the twelve repeat days (p03, p04). Second, ask which rules the app counts and how it ranks them; two honest apps can disagree on half the year (p02, p14). Third, for a request inside a short window, accept that it may have no fully clean answer (p07). Fourth, in rune apps, check that the nine symmetric runes are never shown reversed and that about 0.3125 of runes come up reversed (p09).
Hypothesis · not established
Pre-registered prediction (not yet tested): in records of at least 1,251 small businesses per group, two-year survival does not differ by more than 5 percentage points between those opened on almanac-good days and those opened on other days, once sector and year are accounted for. What would show it wrong: survival on good days is higher by more than 5 points and the difference survives correction for the number of almanac schools tested.
Summary of the book
Almanac rules are Boolean predicates; stacking seven rule sets leaves 0.090 of 2027 pure, and the share falls roughly as the product of the single-rule shares (p01); two schools built from the same components agree barely beyond chance (p02). The twelve officers form a congruence that repeats at the twelve jie, and the jie day depends on the time zone (p03, p04). Stem-branch days and lodges share a 420-day period, and a date’s verdict does not carry from year to year (p05, p06). Short windows are often unsatisfiable, and most days are both good and bad (p07, p08). Only 15 of 24 runes can be reversed, so reversals follow a hypergeometric-binomial law with mean 0.3125 per rune, not one half (p09 to p12). The Shuihudi daybook already held two systems, any ranking of marks decides most of the year, and the Havamal says nothing of reversed runes (p13, p14).
Fan, Y. (2026). Almanac Auspicious Boolean Lattices, Jianchu Twelve-Officer Congruences and Runic Combinatorics: Constraint Satisfaction Paradoxes, Solar-Term Phase Jumps and Elder Futhark Inversion Distributions [黄历择吉布尔格、建除十二直同余与卢恩符文组合学] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090239 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).