Skip to content
Tết −50%Đoàn Viên, only 99,500 VND first yearĐoàn Viên, first year only 99,500 VND, 1 personal reading a yearSee the offer

Blog

Analysing chart data with Python: how rare are Tử Vi patterns?

Chart of how often each Complete Book pattern appears

Scanning every day from 1 January 1960 to 31 December 2019, all 12 hours a day, gives 262,980 charts: the rarest pattern of the Complete Book of Tử Vi Đẩu Số is Quân thần khánh hội, on just 306 charts, about 1 in 859. The most common is Khoa Quyền Lộc củng at 4.90%. This guide shows how to count it yourself with the Python library nhatnguyet.

How the scan works

  • Every solar day from 1960 to 2019 (21,915 days), all 12 hours from Tý to Hợi: 262,980 charts.
  • One gender. We tried male and female on 576 sample charts and the patterns came out identical, because these patterns only look at star positions.
  • Each chart counts once for each pattern it has. The rates are calendar rates, every day and hour weighted equally, not by how many people were actually born.

Steps

  1. Install the library: pip install nhatnguyet.
  2. Loop over days with datetime and over 12 hours, calling tu_vi.lap_la_so_tu_vi.
  3. Call tu_vi.nhan_dien_cach_cuc on each chart and count by pattern name.
  4. Patterns from the Complete Book carry a nhom key: wealth (định phú), rank (định quý) or hardship (định bần tiện), after the book's three tables. Count by table as well.
  5. Print the rates, sorted from rare to common.
from collections import Counter
from datetime import date, timedelta
from nhatnguyet import tu_vi

count = Counter()    # charts carrying each pattern
table = {}           # which table of the Complete Book a pattern belongs to
by_table = Counter()
total = 0

day = date(1960, 1, 1)
while day <= date(2019, 12, 31):
    for hour in range(12):  # 0 is the Tý hour, 11 the Hợi hour
        chart = tu_vi.lap_la_so_tu_vi("", "Nam", day.day, day.month, day.year, hour)
        found = {c["ten"]: c for c in tu_vi.nhan_dien_cach_cuc(chart)}
        total += 1
        for name, c in found.items():
            count[name] += 1
            table[name] = c.get("nhom", "")
        for t in {c.get("nhom") for c in found.values()} - {None}:
            by_table[t] += 1
    day += timedelta(days=1)

print(f"Scanned {total:,} charts")
for t, n in by_table.most_common():
    print(f"  table {t:14} {n:7,} charts  {n / total:6.2%}")
print("The five rarest patterns of the Complete Book:")
for name, n in sorted((x for x in count.items() if table[x[0]]), key=lambda x: x[1])[:5]:
    print(f"  {name:22} {n:5,} charts  {n / total:6.3%}  (about 1 in {round(total / n):,})")

It takes a few minutes on a laptop:

Scanned 262,980 charts
  table dinh-quy        51,718 charts  19.67%
  table dinh-ban-tien   24,503 charts   9.32%
  table dinh-phu        12,951 charts   4.92%
The five rarest patterns of the Complete Book:
  Quân thần khánh hội      306 charts  0.116%  (about 1 in 859)
  Lưỡng trùng Hoa Cái      362 charts  0.138%  (about 1 in 726)
  Tài Lộc giáp Mã          537 charts  0.204%  (about 1 in 490)
  Quyền Lộc sinh phùng   1,184 charts  0.450%  (about 1 in 222)
  Nhật Nguyệt đồng lâm   1,335 charts  0.508%  (about 1 in 197)
Code that scans 262,980 charts and its counts
Code that scans 262,980 charts and its counts

Results: which patterns are rare, which are common?

table of the Complete Bookcharts with at least one patternrate
Rank (định quý)51,71819.67%
Hardship (định bần tiện)24,5039.32%
Wealth (định phú)12,9514.92%
Share of charts with each pattern of the Complete Book
Share of charts with each pattern of the Complete Book
  • Rarest: Quân thần khánh hội 0.116%, Lưỡng trùng Hoa Cái 0.138%, Tài Lộc giáp Mã 0.204%.
  • Most common: Khoa Quyền Lộc củng 4.90%, Nhất sinh cô bần 4.04%, Toạ quý hướng quý 3.35%.
  • All 24 patterns of the three tables appear at least 306 times in this scan.

How to read the numbers

  • These are frequencies of a rule, not of fate. The numbers say how many charts carry a pattern under the school's star-placement rules; they say nothing about the life of the person with that chart. Tử Vi's rules have not been tested.
  • "Rare" does not mean "good". Lưỡng trùng Hoa Cái belongs to the hardship table yet is rarer than almost every rank pattern.
  • For rates among real people, weight each day by the number of births on it; day and hour birth records for Vietnam are not public.

Where to go next

  • Use la_so["cung"] instead of nhan_dien_cach_cuc to count where each star falls, or how many charts have no main star in the Life palace.
  • Scan Bát Tự with bat_tu.lap_la_so_bat_tu and count ten gods or symbolic stars.
  • Compare with the pre-computed readings on the open data page.

The code is MIT. If you quote these numbers, credit "Data: Nhat Nguyet (nhatnguyet.org)" and describe the scan as above. The code repository is on the open source page; the classic patterns are drawn in Tử Vi chart patterns in diagrams.

Tử Vi chartA Tử Vi chart from your birth date and hour: quick read, then each palace.Try it

More from the blog

All blog posts