[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
Anyone can help me with dice?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

File: dice.png (31 KB, 694x458) Image search: [iqdb] [SauceNao] [Google]
31 KB, 694x458
Anyone can help me with dice?

So basically I want a dice-rolling program to give me the odds of rolling a particular number for any amount of any-sided dice

Obviously then I need to be able to calculate the number of possible permutations the dice can use to get any number, but I'm fucking stumped. I googled the problem and got this, but I simply don't understand the equation

I get that this is a "generating" equation, but how do I use it? What is the x variable used for? Do I set this equation equal to x^k, do I set it equal to anything?

>>
"hurrdurr Im retarded cs101 major"

asking the question "what is the probabilty i will get a 3" rolling 2 dices is equivalent to

chance of me getting
3 and 0
2 and 1
1 and 2
0 and 3
>>
>>7775759
What the fuck are you even saying? Dice don't have a 0 face, or at least none I've ever used.
>>
The total number of possibilities is 6^2 because permutations = variables ^ slots.

An easy way to remember this if it's something you have difficulty with is to imagine a 4 digit combination lock with 0-9 for each slot. You know there are 10,000 combinations because the highest number is 9,999 and the lowest is 0. 4^10 does not give 10,000, 10^4 does.

So you know there are 36 permutations, that acts as a checksum for the next method.

List all the possible results. 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12.

Now make a list of all the possible combinations for each number, you know that you have to use 2 numbers, those numbers are all between 1 and 6.

2 = 1+1
3 = 1+2, 2+1
4 = 2+2, 3+1, 1+3
and so on

The total number of data points should be 36 based on the total we worked out earlier.

So rereading your question you didn't want any of this so I won't go further but I'll re-explain the first bit.

Variables ^ slots. Always. Remember the combination lock. Variables in this case = number of sides on the dice, slots = number of dice.

Variables are what can appear in each slot, each slot is which thing can present a number.

If you're ever confused as to which is the variable and which is the slot just reduce both sets down, one to 2 and one to 3. Work out how many data points would arise from the reduced number. If the answer is 8, the one you reduced to 2 is the variable, if the answer is 9 the one you reduced to 3 is the variable.
>>
>>7775785
>>7775785
>The total number of possibilities is 6^2 because permutations = variables ^ slots.
Only 2d6
>>
>>7775800

I didn't read his post properly at first, I explained the concept behind it in the second half of the post.
>>
>>7775812
Except I understand the concept fully, but that still doesn't give me a way to calculate how many possible ways there are to get a roll of 28 on 14d3
>>
>>7775745
For reference, I'm trying to make a program to help me with Warhammer

Most of what I need to roll is, yes 2d6, but 3d6, 4d6, and 4d3 also come up enough that I want a single formula to calculate all the possible permutations of those dice and the chances of them coming up.
>>
>>7775745
It's written right there. Point one tells you how to find the generating function of a die, point two tells you how to get the generating function of a combination of dice by multiplying the generating functions of each single die (i.e. raising it to the power n if you roll n equal dice).
Once you have your generating function, expand the polynomial and look at the coefficient of each power: thct coefficient is the probability of the associated exponent to come up. E.g. if you had a polynomial 0.3*x+0.5*x^2+0.2*x^3, the probability distribution would be p(1)=0.3, p(2)=0.5, p(3)=0.2
This method is much faster than listing all possibilities, in fact it runs in O(r log r log n) instead of O(r^n)
>>
>>7776408

Yes it does.

Create a program that adds <dice> integers between <sides>.

So you would have something that adds 14 numbers 1 + 1 + ... 1 = 14, 1 + 1 + ... 2 = 15 and so on. Then it takes all the sets that add up to 28. That gives you the permutations possible for 28. That number over the total number of permutations, in this case 4,782,969 gives you the probability of rolling 28 on any given throw.