Strange Dice probability

409 Views Asked by At

I started a discussion with some friends trying to understand: if I roll 1 dice of 10(1d10) and 1 dice of 4(1d4) 20 times, and do it again 1000 times. Why the d4 have the probability to score the average(50) or more, more times than the d10???

I also wrote a java code to try to understand that take a look:

double totalDfour = 0;
        double plusDfour = 0;
        double avarageDfour = 50;
        int dfour = 0;

        double totalDten = 0;
        double plusDten = 0;
        double avarageDten = 110;
        int dten = 0;

        Random generator = new Random();

        for (int y = 1; y <= 1000; y++) {
            plusDten = 0;
            plusDfour = 0;
            for (int x = 1; x <= 20; x++) {

                dfour = generator.nextInt(4) + 1;
                Log.d("DADO", " d4: " + dfour);
                plusDfour = plusDfour + dfour;

                dten = generator.nextInt(10) + 1;
                Log.d("DADO", " d10: " + dten);
                plusDten = plusDten + dten;

            }

            if (plusDten >= avarageDten) {
                totalDten++;
            }

            if (plusDfour >= avarageDfour) {
                totalDfour++;
            }

        }
        Log.d(TAG, "Total d10= " + totalDten + " Total d4= " + totalDfour);

And always totalDfour is bigger than totalDten, and i would like to understand why if both have the same probability to score the average number or more.

3

There are 3 best solutions below

1
On

Random generator = new Random();

This is your problem right here. A Rookie programming mistake.

Algorithmic random number generators are not truly random, they are really algorithms that generate a fixed but random-looking sequence of numbers.

Since you are not seeding your generator you are using the same not-really-random sequence every time you run the code.

The classic way to get an approximately distinct sequence is to seed the generator with execution time.

Try using:

Random generator = new Random(System.nanoTime());

0
On

The average of $1d10$ is $5.5$, so the average of $10d10$ is $55$. You have the average of $20d4$ correct. So the chance $20d4 \gt 50$ is less than $\frac 12$ (it is $\frac 12$ less half the chance of exactly $20$ by symmetry), while the chance $10d10 \gt 50$ is greater than $\frac 12$

0
On

The probability that a number of dice rolls produces at least the average can be divided into two components:

  1. The probability that the total is exactly the average. Call this probability $X_4$ for the D4 rolls and $X_{10}$ for the D10s.
  2. The probability that the total is more than the average. Call this $Y_4$ for the D4 rolls and $Y_{10}$ for the D10s.

The probability that the total is more than the average is equal to the probability that the total is less than the average, by symmetry (each possibility that produces more than the average corresponds to a possibility that produces less, and vice versa). Thus, we have

$$X_4+2Y_4=X_{10}+2Y_{10}=1$$ $$X_4+Y_4=\frac{1+X_4}2$$ $$X_{10}+Y_{10}=\frac{1+X_{10}}2$$

$X_4$, the probability that the D4s roll exactly their average, is higher than $X_{10}$, the probability that the D10s roll exactly their average. Intuitively, you can think of the distribution being "chunkier"; there are fewer possibilities for the D4s, so the average happens more. (This isn't very precise, but that's intuition for you.) Thus, $X_4+Y_4$, the probability the D4s roll at least their average, is higher than $X_{10}+Y_{10}$, the corresponding probability for the D10s.


Note that all this depends on the expected value of the dice distribution actually being in the distribution. If you change the number of rolls to, say, 21, then it won't actually be possible to roll a result of 52.5 or 115.5, and the results will be more like you might have expected.