
You can find working python code for this here: https://github.com/unified-moderation-network/salamander/blob/main/src/contrib_extensions/dice/dicemath.py#L108-L116
Notably, this does not equal what you conjectured at 24:56 of the associated video

And you are welcome to use this in any follow-up.