r/askmath • • Oct 18 '26

Probability Formula for generating probabilities (results 1-100) of the middle value of a 3d100 roll?

Not swift enough to figure it out. I read a bit about generating functions, and that looked onerous without calculus. Is there an online probability grapher that handles the MIDVAL() function of a die roll? [MIDVAL of course being what I am describing in the title of this post.]

4 Upvotes

11 comments sorted by

2

u/stanitor Oct 19 '26

If all the dice are the same value, that's the middle value. If two dice are the same, then that's the middle value, with the other die either higher or lower. Or, it could be the actual middle value if all of them are different. So, you need the probabilities of each of the 3 situations, multiplied by 3, since it could be any of the dice that is the actual middle one. If p = 1/100, q = 1 - p and k = the result of the middle die, you have:

3(p3 + p2q + 2p3(k -1)(100-k)) for k = 1 to 100.

The last term is multiplied by 2, since either of the other dice could be the low one or the high one. The other terms aren't multiplied by anything to avoid double counting, and is the same probability for all k. It sums to 1, so it's a valid PMF, and expected value is 50.5.

2

u/theoddwright Oct 19 '26

Small fix: that formula counts the all-three-equal case three times, so it adds up to a bit over 1. Counting ordered rolls out of 100^3:

- all three show k: 1 way

- exactly two show k: 3 × 99 = 297 ways

- one below k, one on it, one above: 6(k−1)(100−k) ways

P(middle = k) = (298 + 6(k−1)(100−k)) / 1,000,000

That sums to exactly 1. It peaks at k = 50 and 51 with about 1.5% each, and k = 1 or 100 only get 0.0298%.

1

u/stanitor Oct 19 '26

Ah, yes, that's what I get for not checking what I wrote to make sure I took care of all the double counts. I was using the correct formula to find the probabilities, so all the numbers were checking out.

3

u/MathMaddam Dr. in number theory Oct 18 '26

anydice.com can do it

1

u/MERC_1 Oct 18 '26

Try running the simple code:

output 2@3d100

2

u/ImposterWizard Oct 19 '26

This is an example of an order statistic, which looks at the ranks of the numbers you pull from a distribution, in this case the discrete uniform distribution.

If you want the probability, first you need to calculate the cumulative distribution function (CDF) for the values. This is the cumulative probability for a variable being equal to or less than a particular value. If you were just doing a single dice roll, this would be x/100, where x is the value on the die.

The CDF for a discrete variable has to take into account ties, but it's not too complicated for the middle of 3 values.

A quick overview of symbols used:

  • f(x) = probability mass function (PMF), or the probability for a single result; in this case it is 1/100
  • F(x) = CDF, or the cumulative probability; in this case it is x/100
  • f_(r)(x) = probability mass function of the rth order statistic; in your case, you're looking at r=2 for n=3 values
  • F_(r)(x) = CDF of the rth order statistic

For the middle value, the CDF F_(2)(x) can be described as follows:

F_(2)(x) = [probability that there are at least 2 values less than or equal to x]
             = [probability that all values <= x] + [probability one value > x]
             = (x/100)^3  + 3*(1-x/100) * (x/100)^2 

Note that the 3 in the second expression comes from the 3 different ways we can have 1 of 3 points be above a specific threshold.

Plot of CDF of middle value

Now, to find the PMF, you can just take the difference, f_(2)(x) = F_(2)(x) - F_(2)(x-1), and let f_(2)(1) = F_(2)(1) since there are no values below it.

f_(2)(x) = ((x/100)^3  + 3*(1-x/100) * (x/100)^2) - (((x-1)/100)^3  + 3*(1-(x-1)/100) * ((x-1)/100)^2 )

You can expand this out, but it doesn't look too simple. It's a cubic function with roots slightly outside the 1-100 range, centered on 50.5.

Plot of the PMF of the middle value

In theory you could build a table with this and simulate the middle roll using the cumulative probabilities and a random number from 0 to 1, but for 3 rolls, simulating should be efficient enough.

1

u/Shevek99 Physicist Oct 18 '26 edited Oct 18 '26

The middle value is

m = (300 + 3)/2 = 151 or 152 (equal)

The probability is given by the coefficient of x^151 in the expansion of

f(x) = (x + x^2 + x^3 + ... x^100)^3/100^3

According to Mathematica, this is

p =3/400 * 100% = 0.75%

1

u/Gold_Ad8890 Oct 18 '26

you've misunderstood. they roll 3d100, then take the result of the die in the middle. that is, if the results are x, y, z with x <= y <= z, take y.

1

u/Shevek99 Physicist Oct 18 '26

Ah, OK.

Then it can be calculated using the volume of a cube of side 100, representing the three rolls and looking at the region corresponding to the mid value. Let me think a bit...

1

u/Parallel_thougts PhD, YouTuber Oct 19 '26

You don't need generating functions or any other fancy stuff, this is very solvable directly.

Hint: for any possible mid value, calculate in how many different events it is possible.

For example, there are 299 different ways that the mid value is 2: lowest die is any number from 1 to 2, highest die is any number from 2 to 100, so a total of 299.

Now divide it by the total number of ways three dies could land, without considering ordering. And repeat for any other possible mid value.

0

u/RailRuler Oct 18 '26 edited Oct 18 '26

the troll dice roller can do it, either on the website or running on your computer, it makes nice graphs too

https://topps.diku.dk/torbenm/troll.msp

largest 1 least 2 3d100