# I Ching simulator with accurate Yarrow Stalk probabilities

I built this because I wanted a digital I Ching that honors the original math, rather than just Math.random(). 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 a…

- **Page:** https://magpie.gallery/i/i-ching-simulator-with-accurate-yarrow-stalk-proba-a4xv
- **Type:** Link to an idea elsewhere
- **Category:** Everyday life
- **Runs on:** web
- **Tags:** i-ching, divination, simulator, probability, yarrow-stalk

## Source

Web · jackzhuo: I Ching simulator with accurate Yarrow Stalk probabilities

- **Original:** https://news.ycombinator.com/item?id=46261942

> I built this because I wanted a digital I Ching that honors the original math, rather than just Math.random(). 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! https://castiching.com/

## Rules for reuse

- Build your own version: don't copy another product's code, look, icons, colours or copy.
- The original belongs to its author; Magpie only links to it.
- The original content's copyright belongs to its creator. Magpie doesn't download or re-upload it; we only show the link and the official preview.
