slug: what-is-dayuan-method-ancient-i-ching-50-yarrow-stalks-oracle-algorithm
title: "What Is the Dayuan Method — Ancient I Ching Oracle Algorithm with 50 Yarrow Stalks" lang: en excerpt: "What is the Dayuan Method (大衍法)? Explore the 3,000-year-old ancient I Ching divination method using 50 yarrow stalks: origins, cosmic philosophy, 18-step procedure, probabilities, and code implementations." publishedat: "2026-04-04T07:48:11.009Z" updatedat: "2026-07-31T09:15:35.812Z"
Dayuan Method (大衍法) — Yarrow Stalk Oracle
1. Origin
The Dayuan Method (大衍法, Dà Yǎn Fǎ), often referred to as the Yarrow Stalk Method, is the oldest surviving divination technique of the I Ching (Book of Changes). It is documented in the Xici Zhuan (繫辭傳, Great Commentary) — the philosophical commentary attached to the core text of the I Ching, dating back to approximately 300–200 BCE (Warring States period).
Original ancient text:
大衍之數五十,其用四十有九。 Dà yǎn zhī shù wǔshí, qí yòng sìshí yǒu jiǔ. "The number of Great Expansion is fifty, of which forty-nine are used." 分而為二以象兩,掛一以象三,揲之以四以象四時, 歸奇於扐以象閏。五歲再閏,故再扐而後掛。 Fēn ér wéi èr yǐ xiàng liǎng, guà yī yǐ xiàng sān, shé zhī yǐ sì yǐ xiàng sì shí, guī qí yú lè yǐ xiàng rùn. Wǔ suì zài rùn, gù zài lè ér hòu guà.
2. Philosophical Significance
Every step in the Dayuan Method carries explicit cosmological symbolism:
- 50 stalks = The Number of Great Expansion — the overarching total representing the cosmos.
- 1 stalk set aside = Taiji (太極, Supreme Ultimate) — the unmanifested, undivided source; kept idle and never manipulated.
- 49 stalks used = The Number of Function (Yong) — all manifest phenomena arising from Taiji.
- Dividing into 2 bundles = Liangyi (兩儀, Two Polarities) — Yin and Yang, Earth and Heaven.
- Extracting 1 stalk = Sancai (三才, Three Powers) — Heaven, Earth, and Humanity.
- Counting by 4s = Sishi (四時, Four Seasons) — Spring, Summer, Autumn, and Winter.
- Remainders collected = Leap Months (Run) — intercalary months in the traditional lunisolar calendar.
3. The 18-Step Procedure (3 Transformations × 6 Lines)
Every I Ching hexagram consists of 6 lines (yao). Determining each line requires 3 successive manipulations (biàn, transformations). In total: .
3.1. A Single Transformation (1 Iteration):
- Start with stalks (49 for the 1st transformation; remaining stalks for subsequent transformations).
- Randomly divide the stalks into 2 bundles (Left and Right).
- Extract 1 stalk from the Right bundle and place it between the pinky and ring fingers of the left hand (representing the Three Powers).
- Count through the Left bundle in groups of 4, keeping the remainder (1 to 4 stalks).
- Count through the Right bundle in groups of 4, keeping the remainder (1 to 4 stalks).
- Sum the remainders (1 extracted stalk + Left remainder + Right remainder) = stalks set aside for this transformation.
3.2. Remainder Values Per Transformation:
- 1st Transformation: Total remainder stalks (only 2 valid outcomes).
- 2nd Transformation: Total remainder stalks.
- 3rd Transformation: Total remainder stalks.
3.3. Line Value Determination:
After 3 transformations, the total stalks removed . The remaining stalks are divided by 4:
- Old Yang (老陽, Lǎo Yáng) — Changing Yang line (value 9)
- Young Yin (少陰, Shǎo Yīn) — Static Yin line (value 8)
- Young Yang (少陽, Shǎo Yáng) — Static Yang line (value 7)
- Old Yin (老陰, Lǎo Yīn) — Changing Yin line (value 6)
4. Probability — Asymmetrical Distribution
Unlike the three-coin method (which yields symmetrical probabilities of for changing lines), the Dayuan Method produces an inherently skewed, asymmetrical probability distribution:
# Dayuan Method Probabilities (Theoretical exact)
probs = {
6: 1/16, # Old Yin (Changing Yin) — 6.25%
7: 5/16, # Young Yang (Static Yang) — 31.25%
8: 7/16, # Young Yin (Static Yin) — 43.75%
9: 3/16, # Old Yang (Changing Yang) — 18.75%
}
# Comparison with the 3-Coin Method:
coin_probs = {
6: 1/8, # Old Yin — 12.5%
7: 3/8, # Young Yang — 37.5%
8: 3/8, # Young Yin — 37.5%
9: 1/8, # Old Yang — 12.5%
}
# The Dayuan Method favors Yin (8) over Yang (7)
# Reflecting philosophical tenets: manifest Yin (phenomenal world) exceeds pure Yang.
5. Algorithmic Implementations
5.1. Python
import random
def yarrow_one_changenstalks:
"""Executes a single transformation (biàn) in the Dayuan Method.
Args:
n_stalks: Current count of active stalks (49 initially)
Returns:
Number of stalks set aside (remainders + 1)
"""
# Randomly divide into two bundles
left = random.randint1,nstalks−1
right = n_stalks - left
# Extract 1 stalk from right bundle Sancai
right -= 1
hand = 1
# Count left bundle by 4s
left_remainder = left % 4
if left_remainder == 0:
left_remainder = 4
# Count right bundle by 4s
right_remainder = right % 4
if right_remainder == 0:
right_remainder = 4
return hand + left_remainder + right_remainder
def yarrow_one_line():
"""Generates a single line yao using 3 transformations.
Returns:
6 (Old Yin), 7 (Young Yang), 8 (Young Yin), or 9 (Old Yang)
"""
stalks = 49
for _ in range(3): # 3 transformations
removed = yarrow_one_changestalks
stalks -= removed
# Remaining stalks divided by 4 yield line value
return stalks // 4
def yarrow_hexagram():
"""Generates a complete 6-line hexagram.
Returns:
List of 6 values [Line 1 bottom to Line 6 top]
"""
return [yarrow_one_line() for _ in range(6)]
# Example usage
hexagram = yarrow_hexagram()
printf"Hexagram: {hexagram}"
for i, line in enumerate(hexagram, 1):
names = {6: "Old Yin ⚋⚋", 7: "Young Yang ⚊", 8: "Young Yin ⚋", 9: "Old Yang ⚊⚊"}
printf" Line {i}: {line} — {names[line]}"
5.2. JavaScript
/**
* Dayuan Method (Yarrow Stalk Oracle Algorithm)
*/
function yarrowOneChangenStalks {
const left = Math.floor(Math.random() * (nStalks - 1)) + 1;
let right = nStalks - left - 1; // -1 for Sancai stalk
let leftRem = left % 4 |
| 4;
let rightRem = right % 4 |
| 4;
return 1 + leftRem + rightRem; // hand + left + right
}
function yarrowOneLine() {
let stalks = 49;
for let i = 0; i < 3; i++ {
stalks -= yarrowOneChangestalks;
}
return stalks / 4; // 6, 7, 8, or 9
}
function yarrowHexagram() {
return Array.from{ length: 6 }, () => yarrowOneLine();
}
// Example usage
const hexagram = yarrowHexagram();
console.log("Hexagram:", hexagram);
5.3. C
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int yarrow_one_changeintnstalks {
int left = 1 + rand() % nstalks−1;
int right = n_stalks - left - 1;
int left_rem = left % 4;
if leftrem==0 left_rem = 4;
int right_rem = right % 4;
if rightrem==0 right_rem = 4;
return 1 + left_rem + right_rem;
}
int yarrow_one_linevoid {
int stalks = 49;
for int i = 0; i < 3; i++
stalks -= yarrow_one_changestalks;
return stalks / 4;
}
int mainvoid {
srand((unsigned)time(NULL));
printf("I Ching Hexagram (Dayuan Method):\n");
for int i = 0; i < 6; i++
printf" Line %d: %d\n", i + 1, yarrow_one_line();
return 0;
}
6. Comparison with Other Divination Methods
- Dayuan Method (蓍草法): Uses 50 yarrow stalks 18 steps asymmetrical probabilities (). Slowest, most solemn, and meditative.
- Three-Coin Method (擲錢法): Tosses 3 coins 1 line per toss. Fast, symmetrical probabilities: , .
- Six-Coin Method: Tosses 6 coins simultaneously 1 hexagram instantly. Fastest, but lacks traditional lineage.
- Mei Hua Numerology (梅花易數): Created by Shao Yong — derives numbers from time, spatial observations, or natural events. Requires no physical tools.
7. Dayuan Method in QuizzMan
Within the QuizzMan I Ching system (lab.quizzman.com), the Dayuan Method is implemented with:
- Visual Simulation: Step-by-step animations depicting the division, counting, and remainder collection across all 18 steps.
- Entropy Source: Employs server-side CSPRNG primitives (
crypto.getRandomValues/os.urandom) rather thanMath.random()to ensure true cryptographic randomness. - Probability Verification: Validated over simulation runs to match theoretical distributions (, , , ).
- Side-by-Side Comparison: Enables users to evaluate identical queries using both the Dayuan Method and the Three-Coin Method to observe distribution variances.