Technical detail for the curious:
The simulation follows the traditional Yarrow Stalk algorithm (Da Yan). The core of this algorithm relies on modulo-4 arithmetic on the stalks remaining after a random split.
To make it physically realistic, I used a Box-Muller transform to simulate the user splitting the stalks with a Gaussian distribution (since humans naturally tend to split near the middle), rather than a uniform random split.
I was worried this 'human bias' might skew the modulo probabilities, so I ran a 1-million-run Monte Carlo simulation to verify.
The Result: The remainders [0,1,2,3] still emerged with a near-perfect 25% distribution (deviation < 0.05%).
So, the app simulates the physics of human imperfection while preserving the mathematical perfection of the probability distribution (where Old Yin is 1/16).
Stack: Next.js + Tailwind css
Happy to answer any questions about the math or the hexagrams!
To be honest, my reason for picking this method was simple: I was reading a book about the I Ching that described the different ways to cast hexagrams.
The Yarrow Stalk method stood out to me because it felt more mysterious—in the past, it seemed like a secret method known only by a few experts.
Also, from a coding perspective, this algorithm was just much more interesting to build than a simple coin toss!
I spent the last 24 hours implementing the feedback from this thread. Thank you all for the harsh (but fair) critique.
1. Ditched AI for the Classics Many of you pointed out that AI interpretations felt "soulless" or risky. I agreed.
Now: The app directly displays the canonical Richard Wilhelm / Cary Baynes translation (Foreword by Carl Jung) for the Primary Hexagram, Moving Lines, and the Relating Hexagram. It's mathematically precise and respects the source material.
2. No More Lost Readings (Persistence) @jmkd mentioned losing a reading on refresh.
Fix: The latest reading is now auto-saved to Local Storage.
Privacy: Still no login required. Your data stays in your browser.
3. Shareable "Result Cards" Since the hexagrams look so cool, I added a feature to generate a downloadable image card. It captures the visual pattern and the key judgment text.
Give it another spin and let me know if the "Moving Lines" logic feels right to you now!
To be honest, I haven't added it because I'm hesitating. I planned to use AI to generate the interpretations, but I'm not sure if that's a good idea.
I feel like letting AI explain the I Ching might kill the 'traditional vibe'.
I'm still deciding: should I use AI, or just use the classic book text? What do you think?
I guess it's a question of philosophy, either split into groups based off of your intuition, or aim for a truly random split in the pile.
Anyway, I wasn't sure if this is something that's a settled matter or what.
You are right that humans don't split perfectly randomly (Uniform Distribution). We tend to aim for the middle but miss slightly.
In my code, I modeled this 'human splitting action' using a Gaussian (Normal) distribution centered at 50% of the pile, with a standard deviation. This simulates the user trying to split the stalks roughly in half, rather than just picking a random number from 0 to 49.
Interestingly, my Monte Carlo simulations showed that even with this human bias (splitting near the middle), the final modulo-4 probabilities remain stable. So the algorithm is robust even against our 'imperfect' hands.
Splitting closer to the middle does make it easier to avoid unintentionally counting though. If you make the same splits every time, you'll get the same outcome of course.
Philosophically / spiritually speaking, "don't think about it too much and just split wherever feels right" is the simple answer. Keep in mind the question you want to ask when you make the split and let whatever happens happen. Close your eyes if it helps you focus.
Yeah I just mean I would be very conscious of splitting with a single stalk in one group and would wonder if that was really a 'fair' selection or something I did intentionally since I know the exact number of the yarrow in one hand. In practice, I can't imagine anyone would make a selection like that, even though in a truly random system it would happen not infrequently.
I recommend buying the book though. It is fascinating whether or not you buy into it.
It got tiring and boring to click and click and click with the mouse with no explanation for how it works
Have you built a web app or a mobile app? I'd love to check out your work if you have a link!
My I Ching tool is located at classicofchanges.com
https://neoching.com
Original Hexagram 45. GATHERING TOGETHER (MASSING) (Ts'ui)
Transformed Hexagram 17. FOLLOWING (Sui)
Ok.
My interpretation for your power supply:
Gathering (45): You need to gather some capacitors? (or maybe a heat sink for the 'massing'?)
Following (17): Clearly it's telling you to use a Voltage Follower. :D
toroid transformer?
Deleted Comment