Show HN: I Ching simulator with accurate Yarrow Stalk probabilities

Posted by jackzhuo 1 day ago

Counter18Comment11OpenOriginal

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!

Comments

Comment by vessenes 12 hours ago

I can’t get this to work on iOS at all - question - coin or yarrow choice - then what? No links seem to be hot/working. A little tutorial would be great. Fun project!

Comment by jackzhuo 9 hours ago

Hi, thank you so much for reporting this!

I just identified the issue (it was a specific mobile browser compatibility bug). I have deployed a hotfix and it should be working now on iOS.

Could you please give it another try? Sorry for the trouble!

Comment by AnonHP 12 hours ago

Same here. It just doesn’t work on Firefox Focus on iOS, even after I disabled content blockers.

Comment by dang 12 hours ago

I put this post in the SCP (https://news.ycombinator.com/item?id=26998308) - will temporarily bury it until the author confirms it's working. Sorry for the inconvenience!

Comment by jackzhuo 9 hours ago

Hi Dan, thanks for the heads up. I have fixed the mobile bug and deployed the update. It should be working for everyone now. I've also replied to the users above.

Comment by typpilol 12 hours ago

Not working on edge on android either

Comment by jackzhuo 9 hours ago

Thank you! I found the bug causing issues on mobile/Edge. Just deployed a fix. It should be working now.

Comment by thenthenthen 8 hours ago

Seems to work on iOS safari!

Comment by jackzhuo 7 hours ago

Great to hear! Thanks for verifying.

Comment by jackzhuo 9 hours ago

Thanks for flagging the Firefox Focus issue. I've just pushed a fix for mobile browsers. It should be loading correctly now. Let me know if it works for you!

Comment by jackzhuo 10 hours ago

sorry, I will check it now!

Comment by 13 hours ago