Is it Random? A Deeper Dive into Fairness and Entropy

(edited)

Hey everyone,

After my last post about the mathematical fairness of the Ultimate Dice Roller, I got some excellent feedback. The gist of it was that a normal distribution over a large scale is a good start, but it doesn't tell the whole story about randomness. The feedback suggested looking into the entropy of the results to get a better measure of their unpredictability.

After a trip down a Wikipedia rabbit hole, I put together a new script to measure the Shannon entropy of the dice roll data. In simple terms, entropy is a measure of surprise or uncertainty. For a fair six-sided die, the ideal entropy is (log2(6)) about 2.585 bits. The closer our measured entropy is to that ideal value, the more unpredictable and fair the rolls are.

The Results

The script I wrote analyzes the dataset of 5,000 3d6 rolls from the last post. It calculates the Shannon entropy based on the frequency of each die face (1 through 6) and compares it to the ideal value. A total of 15,000 dice with 6 sides were compared.

Dear god I hate math so much right now 😅

The analysis of the large_fast_rolls dataset shows a Shannon entropy of 2.5847 bits. This results in a deviation of just -0.01% from the ideal entropy for a fair six-sided die. The verdict from the script is a definite PASS, as the entropy is well within the ±2% tolerance for an ideal distribution.


I also created a script to visualize the entropy on a binary entropy curve. This plot shows how the probability of each individual face contributes to the overall entropy of the system.

Since each face has the same chance they all sit at ≈ 0.167

While the complex math behind the NIST publications suggested in the comments is a bit beyond me, this analysis gives me a high degree of confidence. So, I am once again going to say that yes, the Ultimate Dice Roller is mathematically fair.

The scripts are also in the repository here.

As always,
Michael Garcia a.k.a. TheCrazyGM

0.06616046 BEE
6 comments

Cool 😊

0.00037699 BEE

Congratulations @thecrazygm! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 5000 HP as payout for your posts, comments and curation.
Your next payout target is 6000 HP.
The unit is Hive Power equivalent because post and comment rewards can be split into HP and HBD

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0.00036574 BEE

Very cool, and well done. That certainly seems pretty bloody random. I love this sort of community feedback and continued refinement and improvement, it's super cool to see. 😁 🙏 💚 ✨ 🤙

0.00036204 BEE

Great to see these results!
I don't know your source of randomness, but if it comes from a hash function, I do not doubt the quality of the entropy.

!PIMP & !PIZZA

0.00035548 BEE

Since they are provably fair, the server seed is the current hive block_id, the client seed is the current blocks transaction_merkle_root + salt (to prevent duplicates in fast succession) and the nonce is the block number, It combines the client_seed and nonce into a message, hashes it with HMAC-SHA256 using the server_seed as the key, and then each die roll is the integer value of an 8-hex-digit chunk from the result, modulo the number of sides + 1.

0.00000000 BEE

Amazing! Entrepidous, even!

Can't wait to get the data of the blockchain blocks over time, especially know that we are sure that our salt is fair and entripous. And yes, Im sure thats a word.

!PAKX
!PIMP
!PIZZA

0.00034450 BEE

View or trade PAKX tokens.

@ecoinstant, PAKX has voted the post by @thecrazygm. (1/2 calls)



Use !PAKX command if you hold enough balance to call for a @pakx vote on worthy posts! More details available on PAKX Blog.

0.00033759 BEE

Thor: I need to go to Nidavellir

Drax: Nidavellir? That's a made up word!

Thor: All words are made up

0.00304300 BEE
(edited)

PIZZA!

$PIZZA slices delivered:
ecoinstant tipped thecrazygm
@steemmillionaire(1/5) tipped @thecrazygm

Come get MOONed!

0.00033080 BEE