Why is math so underrated?

General questions, debates, and rants about RPGs

Moderator: Moderators

Thaluikhain
King
Posts: 6185
Joined: Thu Sep 29, 2016 3:30 pm

Post by Thaluikhain »

Isn't it also common for criticals to be possible when normal results aren't, making sure things into almost sure things?
Iduno
Knight-Baron
Posts: 969
Joined: Fri Feb 10, 2017 6:47 pm

Post by Iduno »

Ghremdal wrote:Ok, I get critical successes that are defined via in game rules. I too have my great critical hit story.

What I am headscratching about is the undefined effects. If in Shadowrun 4e I get a critical failure on a perception test, what happens? Bears?
Apparently, any time you get 4 successes over what is required, it's a critical success in Shadowrun. I say "apparently," because the result of a critical success isn't defined anywhere that I could find, or was stupid enough that I chose to forget.

So I guess "yeah, you saw the guard/lack of guards real good." Maybe the GM gives you a point of edge (luck dice) back.
User avatar
Cervantes
Journeyman
Posts: 129
Joined: Mon Jul 28, 2014 10:27 pm

Post by Cervantes »

that was a thought i had - what if "critical success" provided some sort of meta-currency that could be spent on... something

obviously needs some mechanisms to avoid cheesing the system (making easy checks to rack up critical success dice) and some uses for the meta-currency (blunting critical failures, adding dice to roll, etc)

you can think of it as "momentum" - doing really well now makes it easier to do really well later
Iduno
Knight-Baron
Posts: 969
Joined: Fri Feb 10, 2017 6:47 pm

Post by Iduno »

How would I calculate the variance/standard deviation/some percent confidence of a die roll?

Worse, I'm trying to calculate the variance (or standard deviation, or something that gets me similar information) on exploding dice.

I calculated the average of a non-exploding die with x sides as (1+x)/2, and exploding as (1+x)/2+(1/x)((1+x)/2)+(1/x^2)((1+x)/2) because neither excel nor I know how to do proper calculus anymore, and the difference is negligible for the inputs.
User avatar
Cervantes
Journeyman
Posts: 129
Joined: Mon Jul 28, 2014 10:27 pm

Post by Cervantes »

User avatar
Pixels
Knight
Posts: 430
Joined: Mon Jun 14, 2010 9:06 pm

Post by Pixels »

The trick to figuring out the mean of an exploding die is noting that when you explode, the mean of the new die you add is equal to the mean of the original die. So the mean of an exploding d6 is m = (1+2+3+4+5+6)/6 + m/6. Solve for m = 4.2. More generally, m(x) = x*(x+1)/(x-1)/2.
Iduno
Knight-Baron
Posts: 969
Joined: Fri Feb 10, 2017 6:47 pm

Post by Iduno »

Pixels wrote:The trick to figuring out the mean of an exploding die is noting that when you explode, the mean of the new die you add is equal to the mean of the original die. So the mean of an exploding d6 is m = (1+2+3+4+5+6)/6 + m/6. Solve for m = 4.2. More generally, m(x) = x*(x+1)/(x-1)/2.
My method for the mean (I meant mean average before) used the average of the highest and lowest values (1 and x, where x is the number of sides), because all of the possible faces should be equally likely. Exploding dice just add the average a fraction (1/x) of the time, then explode a second time that same fraction of a fraction (1/x*1/x=1/x^2)... 4.2 is what I came up with as well, so at least my shortened calculation got the job done. If I could remember integrals, I think it's integral from zero to infinity of (1+x)/2X^n. I could be way off, as it's been more than a decade.

I was wondering if there is an easy (non-calculus) way to calculate the standard deviation without listing each of the possible results. I'm stuck using excel, as it is the most powerful math tool I have at hand.
User avatar
Cervantes
Journeyman
Posts: 129
Joined: Mon Jul 28, 2014 10:27 pm

Post by Cervantes »

i guess my link wasn't clue enough, use http://www.anydice.com for your dice statistics needs. if you click "summary" it gives you standard deviation

unless you're wanting to calculate that shit manually/directly. in which case i d k
Iduno
Knight-Baron
Posts: 969
Joined: Fri Feb 10, 2017 6:47 pm

Post by Iduno »

Cervantes wrote:i guess my link wasn't clue enough, use http://www.anydice.com for your dice statistics needs. if you click "summary" it gives you standard deviation

unless you're wanting to calculate that shit manually/directly. in which case i d k
I suppose "roll this 400 times" works. It should be similar enough results, and doing full-fat math with the tools I have is...not good.
meschlum
NPC
Posts: 4
Joined: Thu Apr 05, 2018 5:15 am

Post by meschlum »

Iduno wrote:How would I calculate the variance/standard deviation/some percent confidence of a die roll?

Worse, I'm trying to calculate the variance (or standard deviation, or something that gets me similar information) on exploding dice.

I calculated the average of a non-exploding die with x sides as (1+x)/2, and exploding as (1+x)/2+(1/x)((1+x)/2)+(1/x^2)((1+x)/2) because neither excel nor I know how to do proper calculus anymore, and the difference is negligible for the inputs.
Short answer: with an exploding die with S sides, you have:

Mean: S * (S + 1) / (2 * (S - 1))

Variance: S * (S + 1) * (S^2 + 7 * S - 2) / (12 * (S - 1)^2)

So with a D6, you get Mean 6 * 7 / 10 = 4.2 and Variance 6 * 7 * (36 + 42 - 2) / (12 * 25) = 10.64

Standard deviation is the square root of the variance.

Happily the result is infinite in the case of one sided dice, which is as it should be.


Long answer: in spoilers, because I'm not that evil. It's fun, though!
The method described by Pixels is the right way to compute the mean, as it's quick, elegant, and works. Sadly, for the purpose of computing the variance, we need to introduce the slow and ugly method (which also works).

An exploding die with S sides has possible values of 1... S -1, S+1... 2S-1, 2S+1... and so on, with probabilities of 1/S for the first group, 1/S^2 for the second, etc.

You can compute the mean by taking the (infinite) sum of values times their probabilities, and a quick bit of algebra shows it can be expressed as:

Sum(for i=0 to infinite){ ( (i * S + 1) + (i * S + 2) + ... + (i * S + S - 1) ) / S^(i+1) }

Which can be simplified into two parts:

Sum { (i * S * (S - 1)) / S^(i+1) + (1 + 2 + ... + S - 1) / S^(i+1) }

Where the first part is a constant in each step and happens S - 1 times (there are 5 values between 1 and 6 on an exploding D6, 5 values between 7 and 12, etc.). The second part is a constant across all steps, and the sum can be computed.

Using recursion, one can find and confirm that the sum of numbers from 1 to N is N * (N + 1) / 2, so we know the value of the second term in the sum (except for the S^(i+1) part).

Again, we can simplify, moving constants (things that do not depend on i) outside the sum and breaking it into two sums:

S * (S - 1) * Sum { i / S^(i+1) } + S * (S - 1) / 2 * Sum { 1 / S^(i+1) }

Now if only we knew how to compute infinite sums of terms with a power law, we'd be set!

First, the i+1 term is ugly, so let's simplify it to S^i * S. That lets us cut down on the sums a bit more:

(S - 1) * Sum { i / S^i } + (S - 1) / 2 * Sum { 1 / S^i }

Next, note the identity 1 + r + r^2 + ... + r^n = (1 - r^(n+1)) / (1 - r). You can confirm it by multiplying the left side by (1 - r).

So if r < 1 (hint: a die with more than one side), as n goes to infinity, the left hand sum converges to 1 / (1 - r), since r^(n+1) goes to zero.

We have r = 1 / S < 1, so we can use that in the second sum. That gives (S - 1) / 2 * 1 / (1 - 1 / S), so S / 2 (multiply numerator and denominator by S).

The first sum is a bit trickier, because we have 0 / S + 1 / S + 2 / S^2 + ...

Enter the calculus. The derivative of 1 + r + r^2 + ... r^n is 1 + 2*r + 3*r^2 + ... + n * r^(n-1). So if we multiply it by r, we get 1*r + 2*r^2 + ... + n*r^n, which is what we want.

And the derivative of 1 / (1 - r) is simply 1 / (1 - r)^2, so we can use that rather than deal with infinite sums: r + 2r^2 + 3r^3 +... = r / (1 - r)^2

So the first sum of (S - 1) * Sum { i / S^i } is equal to:

(S - 1) * (1 / S) / (1 - 1 / S)^2, which simplifies to:

S / (S - 1)

Adding the two together, we get S * (1 / (S - 1) + 1 / 2), which is equal to S * (S + 1) / (2 * (S - 1)), as stated above.

Why did we bother doing this when easier ways to compute it exist? Because we'll use something very like it for the variance.

Add some probability to the mix: given that E() is the expected value (mean), then for a random distribution X, the variance of X is E(X^2) - E(X)^2. Mind the parentheses.

So to get the variance, we just need to compute the mean of the square of the exploding die, and do a bit more algebra after. So that's a roll on a D6 that is equal to 1, 4, 9, 16, 25, 49, 64...

Fortunately (hah!) the methodology we used before can easily be converted to this. First, the infinite sums:

Sum(for i=0 to infinite){ ( (i * S + 1)^2 + (i * S + 2)^2 + ... + (i * S + S - 1)^2 ) / S^(i+1) }

Which simplifies to a three part sum:

(S - 1) * i^2 * S^2 / S^(i+1)

i * S * 2 * (1 + 2 + ... + S - 1) / S^(i+1)

(1 + 4 + ... + (S - 1)^2) / S^(i+1)

Recursion tells us that the sum of squares from 1 to N^2 is N (N + 1) (2 N + 1) / 6, so we can easily compute the third equation. I'd go into how you can derive the equation for sum of different powers, but the important parts are recursion and the notion that the sum of terms to the power x is a polynomial of degree x+1.

The second equation is made of terms we've already computed (hi, calculus and infinite sums!), so it's easy.

The first equation means we have to dip into calculus again and take the second derivative of the infinite sum 1 + r + r^2 + ..., getting the sum of terms of the form (n^2 - n) * r^(n - 2), and we already know the sum of the -n r^(n-2) part, so we can compute the rest. The derivative of 1/(1-r)^2 is, of course 2/(1-r)^3 (calculus!) and the rest follows.

So with a pile of algebra after that, we can simplify things out to get the mean of the square of an exploding die. Subtract the square of the mean of an exploding die, simplify more, and the solution is as stated.

You're welcome.
Excel answer: the spoiler above reveals that the variance of a variable X is E(X^2) - E(X)^2, so if you just do a SUMPRODUCT on enough terms you can get an approximation. There are ways to speed things up, but if you wanted to do it quickly you'd use the final equations anyway.

For a D6 with the basic version, you'd have

1 1 1/6
2 4 1/6
3 9 1/6
4 16 1/6
5 25 1/6
6 36 0
7 49 1/36
8 64 1/36
9 81 1/36
10 100 1/36
11 121 1/36
12 144 0
13 169 1/216
...

Where you compute the SUMPRODUCT of the first and last column to get the mean, and get the variance by taking the SUMPRODUCT of the second and third columns, then subtracting the square of the mean.

As you add more terms, the approximation comes closer.

Edit: If you just want an approximation, the following should do:

Normal die: Mean is (S + 1) / 2, Variance is S^2 / 12

Exploding die: Mean is normal die mean times S/(S-1), Variance is (S + 5)^2 / 12, so with an exploding D6 you get 20% more mean (6/5) and roughly the variance from a normal D11.

These values are not exact, but a lot easier to deal with if you want to get a feel for the results.
Last edited by meschlum on Fri Apr 06, 2018 2:24 am, edited 1 time in total.
Post Reply