View Full Version : Math Help: roll 4d6 keep drop one

cupkeyk

2010-10-08, 03:37 AM

Hi playgrounders.

I will be playing l5r soon and i want to know how to compute the average dice for that game.

It uses the roll and keep system. Basically you roll a dice pool of X number and keep y number of results.

What's the math for that?

holywhippet

2010-10-08, 05:29 AM

I'm not following what you mean. How are X and Y variable? Are they always in proportion like Y = X /3 or does it depend on skills or something?

Eloel

2010-10-08, 05:39 AM

I'm not following what you mean. How are X and Y variable? Are they always in proportion like Y = X /3 or does it depend on skills or something?

Take them random, I haven't been able to calculate this, so I'd love to hear a mathematical explanation as well.

Roll x dY dice, add up the highest z of them.

BobVosh

2010-10-08, 05:40 AM

The X pool is reliant on your stat, and the Y pool on your skill. (IIRC)

So you have a stat of 3 (average) and a skill of 2, you roll 3D6 and keep 2 of those dice.

I think.

X is 1-5, and Y is the same. Again I believe.

*edit* I thought it was only D6s? Oh well, I haven't played it in years.

Radar

2010-10-08, 06:06 AM

Calculating the probable results of a sum of dice rolls is fairly simple (at least to write down in a neat formula). To wits:

A single d6 roll is a random variable with an even probability for every outcome (numbers from 1 to 6). If you add up a number of rolls, you calculate the resulting probability through convolution (http://en.wikipedia.org/wiki/Convolution) (two at a time). So if Xi are the separate rolls, convolution is * and f_Xi (_ instead of a lower index) is the probability distribution of Xi, then it can be written as:

Y=X1+X2+X3+...

f_Y=f_X1*f_X2*f_X3*...

Convolution for discrete distributions will be calculated through a sum instead of an integral:

(f_X1*f_X2)(k)=Sum_i f_X1 (i)f_X2 (k-i)

With "i" going through all possible values (technically through all integers).

Once you have the distribution, the avarage is calculated as usual:

Sum_i f(i)i

The real problem is to account for the discarded dice. I think, I have found a solution by sorting the rolls in a way. It is still kind of tricky. First of: the probability of getting at least a single 1 on a dM dice in N rolls can be easily calculated through combination with repetitions (I'll write Cr(N,M) here as picking N times from M possible results):

P(1,N,M)=Cr(N-1,M)/Cr(N,M)

Where Cr(N,M)=(N+M-1)!/N!/(M-1)!

Now the probability of getting at least one 2 and not a single 1:

P(2,N,M)=Cr(N-1,M-1)/Cr(N,M)

Decreasing M means, we are excluding 1 from possible results. Overally the probability of getting at least one k without any k-1 or lower is:

P(k,N,M)=Cr(N-1,M-k+1)/Cr(N,M)

The above gives the probability distribution for the lowest die you will get, while rolling NdM. Having that you can get the second lowest die as (probabilities will be named P2, so they won't mix):

P2(1,N,M)=P(1,N,M)P(1,N-1,M)

P2(2,N,M)=P(1,N,M)P(2,N-1,M)+P(2,N,M)P(1,N-1,M-1)

P2(k,N,M)=Sum_i P(i,N,M)P(k-i+1,N-1,M-i+1)

Subsequent dice are obtained in the same manner:

Pj(k,N,M)=Sum_i P(j-1)(i,N,M)P(k-i+1,N-j+1,M-i+1)

This way you get the probability distributions for an ordered set of dice rolls. Pick any number of highest ones and calculate distribution of their sum using convolution. Doing it by hand might be quite tedious, but it's should be easy to implement in any programming language. If you really need it, I might do it in Fortran.

Diarmuid

2010-10-08, 10:06 AM

In your example, are you keeping the highest 2 of the 3 rolls? How would you do this on a table with real dice?

Duke of URL

2010-10-08, 10:17 AM

If someone does write a generic program to calculate these probabilities, I'd love to see it. Intuitively, I know what the general shapes of distributions will be when using XdY, keep Z, but for some comparisons I want to run, I'd like to actually have the precise numbers.

Fax Celestis

2010-10-08, 10:26 AM

In your example, are you keeping the highest 2 of the 3 rolls? How would you do this on a table with real dice?

I'd roll 3d6 and then pick up the one with the lowest face. :smallconfused:

Diarmuid

2010-10-08, 10:29 AM

If that's how L5R handles it, then I know it certainly can be done.

I dont know the scripting involved but I've seen multiple rollers that can do

roll=4d6(takehighest3)

Duke of URL

2010-10-08, 10:32 AM

Generating the values is easy. Determining the statistical properties is harder, as noted in an earlier post.

Eloel

2010-10-08, 10:34 AM

XdY best Z

If you set Z to 1, a simple algorithm like

a = Y ^ (X+1)

for (i=1 to i=(y-1))

{a = a - i^X

}

a = a / Y^X

should work. Though I have no idea how to increase Z in that one and I haven't tested it, my logic might be flawed.

Edit: I just realized this finds the maximum. I'll leave this post here so people could be inspired to think before they post (unlike me)

Kzickas

2010-10-08, 10:36 AM

Generating the values is easy. Determining the statistical properties is harder, as noted in an earlier post.

Generate a few ten thousand values, then plot them.

When it comes to probability a good rule to live by is "when in doubt simulate"

Eloel

2010-10-08, 10:39 AM

Generating the values is easy. Determining the statistical properties is harder, as noted in an earlier post.

When you're using a computer to generate the values, you might as well go the all way and generate all data.

Something like

"5d6 best 3? I'll just generate all 6^5 values and take the average."

gomipile

2010-10-08, 10:55 AM

When I figured the probabilities for 4d6 drop the lowest and 5d6 keep the best 3 (for D&D character generation) I had a computer generate every result. This does not take much storage, as all you need are the variables for the individual dice which are rolled each round, and an array the same size as the number of possible values, of which you increment an element by 1 after you add up the value of the current roll.

So you just end up with a sequence of nested loops to roll all of the dice in every possible combination, and it outputs a list of the number of times that each possible result was rolled.

For XdY keep the highest Z, the computation time does grow at least as fast as as Y^X, which is bad. However, for practical purposes in roleplaying games, the number of dice never gets high enough for a modern computer to take very long to churn out the entire table. You do sometimes have to make sure you are using wide enough floating point numbers that you can do the division at the end to get the probabilities, though.

Duke of URL

2010-10-08, 10:57 AM

When you're using a computer to generate the values, you might as well go the all way and generate all data.

Something like

"5d6 best 3? I'll just generate all 6^5 values and take the average."

The problem with doing that is that as an amateur, you kind of have to rewrite the logic for each equation you want evaluated. A better approach would be a more generic, flexible program to calculate the average and distribution, which is what I'm expressing an interest in seeing. Given enough time to think about it, I could probably write such a program myself, but I'm just as happy to leech off of someone else's work. :smallwink:

Lapak

2010-10-08, 11:06 AM

I was actually wrestling with a similar problem yesterday, and it's been far too long since I dealt with probabilities in any significant way for me to come up with a satisfactory answer. What's the best approach to calculate the odds of rolling Z sets of XdY and taking the best? In this case, I'm wondering what the average result of "3d6 rolled twice, take the better result" would be. And "3d6 rolled three times, take the best result" as well.

Eloel

2010-10-08, 11:07 AM

The problem with doing that is that as an amateur, you kind of have to rewrite the logic for each equation you want evaluated. A better approach would be a more generic, flexible program to calculate the average and distribution, which is what I'm expressing an interest in seeing. Given enough time to think about it, I could probably write such a program myself, but I'm just as happy to leech off of someone else's work. :smallwink:

I'll just give a train of thought - can't really be bothered to flesh out the program.

Create 2 arrays of size X (say, A and B), and an array of size Y*Z (say C). Fill array A with all 1s. Sort them descending into array B, take first Z terms, add them together, +1 the corresponding term in array C.

Add 1 to array A's last term, repeat. Make sure that if a term in array A is above Y, it drops back to 1, adding 1 to the item to the left of it. When first term in array A reaches Y+1, you're done with the simulation.

Now go to array C, multiply every term with the count in it, add them together, and divide to the total number of terms.

Not short (nor really efficient) by any means, but should be easy to program.

ericgrau

2010-10-08, 11:21 AM

The math is much more complicated than writing a program to simply roll 10,000 times and take the average. I've done this before and IIRC it was almost the same as the elite array: 15, 14, 13, 12, 10, 8. Except it was slightly closer to 16,14,13,12,10,8. The high roll was around 15.6 or 15.7. I can try to dig up the program or redo it if you want me to confirm. It might have results for other rolling methods too, I forget.

Side note: This is about the 5th time I've done the math on something and found the SRD to be ridiculously accurate. I think WotC used to employ a lot of nerds.

Radar

2010-10-08, 12:19 PM

The problem with doing that is that as an amateur, you kind of have to rewrite the logic for each equation you want evaluated. A better approach would be a more generic, flexible program to calculate the average and distribution, which is what I'm expressing an interest in seeing. Given enough time to think about it, I could probably write such a program myself, but I'm just as happy to leech off of someone else's work. :smallwink:

I might have time to write it by tomorow. Monte Carlo methods (using a sample of random rolls) might give meaningful results, but it's always better to have exact numbers, if you can.

Renchard

2010-10-08, 12:36 PM

Go to anydice.com

Enter:

output [highest Z of YdX]

It will show the distribution for any combination of Y X-sided dice, keep the highest Z dice.

Duke of URL

2010-10-08, 12:40 PM

Go to anydice.com

Enter:

output [highest Z of YdX]

It will show the distribution for any combination of Y X-sided dice, keep the highest Z dice.

Sweet! Exactly what I was looking for! I knew someone must have already done this...

Lapak

2010-10-08, 12:45 PM

Go to anydice.com

Enter:

output [highest Z of YdX]

It will show the distribution for any combination of Y X-sided dice, keep the highest Z dice.Thank you! I'd just managed to work through my own question, but the highest-of function there confirmed my results. In much less time, too. :smallsigh:

EDIT: Huh. There are differences. I'll have to look at my numbers again.

EDIT again: Aha. Found my problem. That link was extremely useful.

Radar

2010-10-08, 03:30 PM

Go to anydice.com

Enter:

output [highest Z of YdX]

It will show the distribution for any combination of Y X-sided dice, keep the highest Z dice.

Thanks! Less work for me. :smallbiggrin:

sonofzeal

2010-10-08, 03:58 PM

I'd be very interested if someone can derive an actual stats formula for it. I've never been able to, personally.

Eloel

2010-10-08, 04:02 PM

I'd be very interested if someone can derive an actual stats formula for it. I've never been able to, personally.

I've been trying on and off for most of today. Didn't even get close.

Chess435

2010-10-08, 04:16 PM

I'm too lazy to do the actual math so I'll just roll 100 times and give you the average:

Edit: Epic dice fail. I'll be right back.

Chess435

2010-10-08, 04:20 PM

Sorry for double post, hopefully the dice work this time:

Chess435

2010-10-08, 04:21 PM

AAH!!!! Why won't you work, dice?

*facepalm*I just realized that the roller doesn't work in this forum section.

Bruendor_Cavescout

2010-10-08, 04:28 PM

Just to add another wrinkle to the analysis, L5R uses d10s. The actual mechanic is "roll a number of d10s equal to your Skill+Trait, keep a number of those d10s equal to your Trait." Additionally, 10s explode, so you can theoretically get really high numbers from one roll.

In the analysis I've seen, 1k1 turns out to be approximately 6.1, so 2k2 is about 12.2, 3k3 is about 18.3, etc. Extra rolled dice increase those numbers at a much slower rate. Three rolled dice is worth about the same amount as one kept die (so, 5k2 is about as good as 3k3).

Eloel

2010-10-08, 04:39 PM

(so, 5k2 is about as good as 3k3).

As a matter of fact, 4k4 is better, on average, than infininityk2. Yep, extra kept dice IS good.

Edit: Nvm, forgot exploding.

Powered by vBulletin® Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.