How many Dice Rolls Would It Take to Reach Your Favorite Kind of Number?

By Lucy Martinez and Doron Zeilberger

.pdf    .tex

published in Maple Transactions, Vol. 3 No. 3 (2023).

Inspired by a recent beautiful paper [arxiv version] by Noga Alon and Yaakov Malinovsky, we extend it in several directions. First we consider dice with other number of faces, rather than the usual 6, and second consider what happens if you don't start at 0, but further on, and third consider many other properties that a natural number can have, not just that of being a prime.

In the process we show the great power of symbolic computation (i.e. "symbol-crunching") as opposed to mere numerical computation (i.e. "number-crunching") to efficiently get both symbolic and numeric output. We conclude with some philosophical remarks that often so-called "rigorous" error-analysis as done brilliantly in the Alon-Malinowsky paper (that was the inspiration to our paper) is only of theoretical interest, since it tacitly assumes that we live for ever, that unfortunately we don't.

Written: Jan. 31,2023

# Maple packages

• HIT1.txt, a Maple package to simulate and approximate expected time of dice rolls until getting to your favorite kind of numbers, using the Alon-Malinovsky approach

• HIT2.txt, a Maple package to simulate and approximate expected time of dice rolls until getting to your favorite kind of numbers, using our generating function approach. It also gives higher moments.

# Sample Input and Output for HIT1.txt

• If you want to see estimates for the expected duration of rolling a fair die with N faces (starting at 0 and adding up the outcomes) until reaching a prime, for N from 2 to 15
the input file yields the output file

• If you want to see estimates for the expected duration of rolling a fair die with N faces (starting at 0 and adding up the outcomes) until reaching a product of two primes, for N from 2 to 15
the input file yields the output file

• The following file has lists in the form [a_1,a_2,...,a_40],[init=x,f=1..40] that gives the expectated duration of the prime-seeking die-rolling game for dice with i-faces for i=2..40 and with initial value x, but rather than starting at 0, starting at all the non-primes ≤ 20
output file

[In other words, for any fixed initial value, it shows how it varies with different number of faces]

• The following list of lists in the form [a_1,a_2,...,a_{13}],[init=0..20,f=y] gives the expectation time number for a prime sum where a_i corresponds to the expectation time of the dice for fixed number of faces y and initial values 0..20 such that the initial value is non-prime

[In other words, for any fixed number of faces, it shows how it varies with different starting non-primes]

# Sample Input and Output for HIT2.txt

• If you want to see the number of rounds, starting at 0, and adding up the outcomes, until you are guaranteed to reach a prime with probability
1-10-7,
followed by the (conditional on that happening) for fair dice from 2 faces to 40 faces the
the input file yields the output file

• If you want to see the number of rounds, starting at 0, and adding up the outcomes, until you are guaranteed to reach a prime with probability
1-10-20,
followed by the (conditional on that happening) for fair dice from 2 faces to 40 faces the
the input file yields the output file

• If you want to see the number of rounds, starting at 0, and adding up the outcomes, until you are guaranteed to reach a PRODUCT OF TWO DISTINCT PRIMES with probability
1-10-7,
followed by the (conditional on that happening) for fair dice from 2 faces to 40 faces the
the input file yields the output file

• If you want to see the number of rounds, starting at 0, and adding up the outcomes, until you are guaranteed to reach a PRODUCT OF THREE DISTINCT PRIMES with probability
1-10-7,
followed by the (conditional on that happening) for fair dice from 2 faces to 40 faces the
the input file yields the output file

• If you want to see the number of rounds, starting at 0, and adding up the outcomes, until you are guaranteed to reach a PRODUCT OF FOUR DISTINCT PRIMES with probability
1-10-7,
followed by the (conditional on that happening) for fair dice from 2 faces to 20 faces the
the input file yields the output file

• If you want to see the number of rounds, STARTING at 2, and adding up the outcomes, until you are guaranteed to reach a PERFECT SQUARE with probability
1-10-6,
followed by the (conditional on that happening) for fair dice from 2 faces to 10 faces the
the input file yields the output file

• If you want to see the number of rounds, STARTING at 2, and adding up the outcomes, until you are guaranteed to reach a PERFECT CUBES with probability
1-10-2,
followed by the (conditional on that happening) for fair dice from 2 faces to 6 faces the
the input file yields the output file

• If you want to see the number of rounds, STARTING at 2, and adding up the outcomes, until you are guaranteed to reach a PERFECT CUBES with probability
1-10-3,
followed by the (conditional on that happening) for fair dice from 2 faces to 5 faces the
the input file yields the output file

[Note: 6 faces did not make the cut-off!]

• Suppose that you are allow up to 200 dice-rolls (don't worry, the probability that you won't get a prime is less than 10-18 in all the cases here), to see not only the expected duration, but also the expected destination, as well as the correlation (not suprisingly close to 1, but a bit surprisingly not that close, e.g. for the usual six-faced fair die it is 0.9656445377, for number of faces from 2 to 20
the input file yields the output file

• If you want to see 102 digits of the Alon-Malinovsky constant (a "non-rigorous" estimate, but absolutely certain)
the input file yields the output file

• If you want to see the expected duration, expected destination etc. with the usal fair 6-faced die, but starting at all non-primes from 1 to 100
the input file yields the output file

• If you want to see the expected duration, expected destination etc. with the usal fair 6-faced die, but starting at all powers of 10 from 100 to 1010:
the input file yields the output file

If you want to see what happened with a loaded coin where when it is Heads you advance 1, and when it is TAILS you advance 2, starting at 1010, for Pr(H) from 1/100 to 99/100 (incremented by 1/100)
the input file yields the output file

If you want to see plots of how, with various starting places, the expected duration changes with the number of faces with a fair die, see
plot file

Articles of Doron Zeilberger