ABOUT
The methods
Yarrow stalks (Da Yan)
From the Great Treatise: the number of the Great Expansion is fifty, of which forty-nine are used. Set one stalk aside for the Ultimate and work with forty-nine. Each change has four operations: divide the bundle at random into two heaps; take one stalk from the right heap and hold it between the fingers; count each heap off in fours and set aside the remainder (one to four, taking four when the count is exact). Three changes make one line; eighteen make a hexagram.
After three changes the remaining stalks must number 36, 32, 28 or 24; divided by four these give nine (old yang), eight (young yin), seven (young yang) and six (old yin). Nine and six are the changing lines. The four are not equally likely: old yang 3/16, young yang 5/16, young yin 7/16, old yin 1/16. This asymmetry is a genuine feature of the ancient method. The animation here simulates the full procedure, and its output matches those probabilities.
Three coins
Throw three coins; heads count three, tails two. Their sum gives six to nine, one line per throw, six throws in all. Standard since the Song dynasty. Compared with the stalks, old yang and old yin are equally likely here (1/8 each), giving a symmetrical distribution.
Plum Blossom
Attributed to Shao Yong. The upper trigram is (year branch + month + day) mod 8; the lower is (year branch + month + day + double-hour) mod 8; the moving line is the same total mod 6, a remainder of zero taking the full value. Trigram numbers follow the Earlier Heaven order: Qian 1, Dui 2, Li 3, Zhen 4, Xun 5, Kan 6, Gen 7, Kun 8. The method yields a single moving line and judges by the five-phase relation between subject and object — a different logic from the classic text.
On randomness
This site uses the browser's crypto.getRandomValues() rather than the ordinary Math.random().