一卦
About Yi Gua

Probability and statistical reasoning

The mathematical model of the Dayan yarrow-stalk method

Based on the derivation provided by the site owner, this page explains the site’s casting model through three transformations, congruences, and transitions between discrete states.

1. Three transformations and remainders

“The number of the Great Expansion is fifty; of these, forty-nine are used.” Each line starts with 49 stalks and goes through three rounds of dividing into two piles, setting one stalk aside, counting in fours, and collecting the remainders. For a nonempty handful, an exact division is assigned a remainder of 4:

r(n)=1+((n−1) mod 4),n≥1r(n)=1+((n-1)\bmod 4),\quad n\geq1

First transformation: remove 5 or 9

L1+R1=49,L1+(R1−1)=48≡0(mod4)L_1+R_1=49,\quad L_1+(R_1-1)=48\equiv0\pmod4

Let x and y be the remainders after counting in fours, each between 1 and 4. Their sum x+y can only be 4 or 8. Including the single stalk set aside, the total removed, D₁, is as follows:

The four equally likely remainder classes in the first transformation
xyRemoved, including the stalk set aside
135
225
315
449
P(D1=5)=34,P(D1=9)=14P(D_1=5)=\frac34,\qquad P(D_1=9)=\frac14

Second and third transformations: remove 4 or 8

After the first transformation, 44 or 40 stalks remain, both multiples of 4. After setting one stalk aside, the total is congruent to 3 modulo 4.

N≡0(mod4)  ⟹  N−1≡3(mod4)N\equiv0\pmod4\;\Longrightarrow\;N-1\equiv3\pmod4

The remainders can sum only to 3 or 7. The pairs (1,2) and (2,1) remove 4 stalks including the stalk set aside; (3,4) and (4,3) remove 8. This holds for every state reachable in the subsequent transformations:

P(Dj=4∣N)=P(Dj=8∣N)=12,j=2,3P(D_j=4\mid N)=P(D_j=8\mid N)=\frac12,\quad j=2,3

A state is defined by the transformation number and the number of stalks remaining. The next state depends only on the current state and the random remainder in that transformation, so the procedure can be viewed as a finite-step Markov process. This is a mathematical description, not proof of metaphysical efficacy.

2. Distribution of the four line types and expected value

X=49−D1−D2−D34∈{6,7,8,9}X=\frac{49-D_1-D_2-D_3}{4}\in\{6,7,8,9\}
Three-transformation paths and probabilities of the four line types
Line type / valueRemoval combinationsRemainingProbability
Old yang 9(5,4,4)36
34⋅12⋅12=316\frac34\cdot\frac12\cdot\frac12=\frac3{16}
Young yin 8(5,4,8)、(5,8,4)、(9,4,4)32
2(34⋅14)+14⋅14=7162(\frac34\cdot\frac14)+\frac14\cdot\frac14=\frac7{16}
Young yang 7(5,8,8)、(9,4,8)、(9,8,4)28
34⋅14+2(14⋅14)=516\frac34\cdot\frac14+2(\frac14\cdot\frac14)=\frac5{16}
Old yin 6(9,8,8)24
14⋅12⋅12=116\frac14\cdot\frac12\cdot\frac12=\frac1{16}

The weights for 6, 7, 8, and 9 are 1, 5, 7, and 3 respectively, totaling 16.

E(X)=9(3)+8(7)+7(5)+6(1)16=12416=7.75E(X)=\frac{9(3)+8(7)+7(5)+6(1)}{16}=\frac{124}{16}=7.75

7.75 is the mean of the numerical encoding used for line values. Young yin is the most probable individual outcome, but yin and yang each account for half of the total:

P(yang)=5+316=12,P(yin)=1+716=12P(\mathrm{yang})=\frac{5+3}{16}=\frac12,\quad P(\mathrm{yin})=\frac{1+7}{16}=\frac12

The expected value therefore cannot establish a “conservation of yin softness” or any other philosophical proposition. “Yang changes readily, yin with difficulty” may serve as a cultural interpretation; what the model directly establishes is that old yang occurs more often than old yin.

3. Changing and unchanging lines, and special cases

Whether a single line changes

Let M denote a changing line. Old yang 9 and old yin 6 change; young yang 7 and young yin 8 do not.

P(M)=3+116=14,P(Mc)=5+716=34P(M)=\frac{3+1}{16}=\frac14,\qquad P(M^{c})=\frac{5+7}{16}=\frac34

When the six lines are independent, the total number of changing lines, K, follows a binomial distribution:

K∼Binomial⁡(6,14),P(K=k)=(6k)(14)k(34)6−kK\sim\operatorname{Binomial}(6,\tfrac14),\quad P(K=k)=\binom6k(\tfrac14)^k(\tfrac34)^{6-k}

All six lines unchanging

P(K=0)=(34)6=7294096≈17.80%P(K=0)=(\tfrac34)^6=\frac{729}{4096}\approx17.80\%

Use Nine: all six lines are old yang, Qian changing to Kun

P(all 9)=(316)6=72916777216≈0.00435%P(\mathrm{all\ 9})=(\tfrac3{16})^6=\frac{729}{16777216}\approx0.00435\%

Use Six: all six lines are old yin, Kun changing to Qian

P(all 6)=(116)6=116777216≈0.00000596%P(\mathrm{all\ 6})=(\tfrac1{16})^6=\frac1{16777216}\approx0.00000596\%

Here, “Use Nine” and “Use Six” refer specifically to the site’s display conditions when all six lines are 9 or all six are 6. This does not equate every ancient rule of divinatory interpretation with those conditions. All old yin is the rarest specific sequence of six line values in this model.

4. Pi changing to Tai

Pi has Qian above and Kun below. For all six lines to reverse and form Tai, the upper three must be old yang and the lower three old yin. The program’s array runs from the bottom line to the top, so it is [6, 6, 6, 9, 9, 9]; reading the diagram from top to bottom gives [9, 9, 9, 6, 6, 6].

A. Joint probability before any casting

P(Pi→Tai)=(316)3(116)3=2716777216≈0.000161%P(\mathrm{Pi}\to\mathrm{Tai})=(\tfrac3{16})^3(\tfrac1{16})^3=\frac{27}{16777216}\approx0.000161\%

B. Conditional probability given an initial hexagram of Pi

P(9∣yang)=3/168/16=38,P(6∣yin)=1/168/16=18P(9\mid\mathrm{yang})=\frac{3/16}{8/16}=\frac38,\quad P(6\mid\mathrm{yin})=\frac{1/16}{8/16}=\frac18
P(Tai∣Pi)=(38)3(18)3=27262144≈0.0103%P(\mathrm{Tai}\mid\mathrm{Pi})=(\tfrac38)^3(\tfrac18)^3=\frac{27}{262144}\approx0.0103\%

This can also be checked by dividing the joint probability by the probability of Pi:

P(Pi)=(12)6=164,27/167772161/64=27262144P(\mathrm{Pi})=(\tfrac12)^6=\frac1{64},\quad \frac{27/16777216}{1/64}=\frac{27}{262144}

These two probabilities answer different questions and are not interchangeable. The symbols Pi and Tai refer to the corresponding hexagrams.

5. The implementation and observed statistics

The program maps a uniformly random integer to one of 16 equally likely states, then obtains a line from the three-transformation result. Tests enumerate all 4⁶ = 4096 sequences of line values, weighting them by 1, 5, 7, and 3, to verify the theoretical probabilities of every initial and resulting hexagram, Use Nine, Use Six, and Pi changing to Tai. They do not rely solely on a small random sample.

The theoretical distribution does not predict visitor behavior. Site statistics are affected by self-selection, tracking opt-outs, and sample size. An association between casting again and opening the source text does not establish causation, nor does it imply dissatisfaction with the previous hexagram.