Dice probabilities
|
04-30-2024, 07:30 PM
Post: #21
|
|||
|
|||
RE: Dice probabilities
(04-29-2024 06:07 PM)Thomas Klemm Wrote: We might rather write it: \(x^2+x^1+x^0\) I'm lost. What is x? Why do create \(x^2+x^1+x^0\)? How does it relate to the dice? Sorry for being dense. Dave |
|||
04-30-2024, 08:26 PM
Post: #22
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 07:30 PM)David Hayden Wrote: What is x? Why do create \(x^2+x^1+x^0\)? How does it relate to the dice? It is a convenience tool. Example, with a fair coin: Coin = (H + T)/2 Coin^2 = (HH + HT + TH + TT)/4 If we don't care permutations, and let number of heads = x exponent, we have Coin = (x + 1)/2 Coin^2 = (x^2 + 2x + 1)/4 Set x=1, we get total probability of 100% (as expected) |
|||
04-30-2024, 09:10 PM
Post: #23
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 07:30 PM)David Hayden Wrote: What is x? Why do create \(x^2+x^1+x^0\)? How does it relate to the dice? A polynomial in the variable \(x\) can be considered an encoding of vector. You are probably more familiar using the other direction: a vector can be considered an encoding of polynomial. If you want to solve \(x^2 - 5x + 6 = 0\) with an HP-48GX you enter: [1 -5 6] PROOT [2 3] But we have a vectors like [1 1 1] or [1 2 3] and we encode them as polynomials \(x^2+x+1\) or \(x^2+2x+3\). How are these vectors related to a die? The position or index marks the value of a side and the coordinate marks how many sides we have with this value. Similarly for a polynomial the exponent marks the value of a side and the coefficient marks how many sides we have with this value. Thus [1 1 1] should rather be [2 2 2] for a real die but we can just scale this up or down. So we don't bother. An ordinary 6-sided die would be encoded as: [1 1 1 1 1 1 0] If you roll multiple dice we assume that their outcome is independent from each other. Every possible event of one die can be combined with every possible event of the other dice. We simulate the same behaviour with the distributive law when two polynomials are multiplied. Every term of one polynomial is multiplied by every possible term of the other polynomials. And that's all there is. But multiplication of polynomials does more that just that. Terms of \(x\) with the same exponent are collected and added. But for the dice this means that events with the same sum are collected and added. And that is exactly what we want. Thus by multiplying these polynomials we can simulate throwing the dice. If that didn't help, I suggest to take two ordinary dice, encode them as polynomials, multiply them and see what happens. And then compare this result to what you would do with the dice. Here comes the really cool part: multiplication of polynomials is easy. It is implemented in many libraries or tools. And if you check my Post #13 you notice that there is a relationship to the Fast Fourier Transform. This allows us to do these kind of calculations very efficiently using an HP-48GX. |
|||
04-30-2024, 09:57 PM
Post: #24
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 07:30 PM)David Hayden Wrote: I'm lost. What is x? Why do create \(x^2+x^1+x^0\)? How does it relate to the dice? You got to it before me! This is witchcraft to me. When I first looked at it I thought it was some kind of maths abuse but I'm willing to reconsider this after more thought. |
|||
04-30-2024, 10:00 PM
Post: #25
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 12:27 AM)Thomas Klemm Wrote: Not really: (x^2+x+1)^5 Interesting and informative discussion here. No real need for Wolfram Alpha, though. On the HP 50, 'X^2+X+1' 5 ^ EVAL is almost instantaneous. For larger polynomials, the Haskell program at A027907 is very fast and easy to implement using DOLIST. |
|||
04-30-2024, 10:07 PM
Post: #26
|
|||
|
|||
RE: Dice probabilities | |||
05-01-2024, 03:32 AM
Post: #27
|
|||
|
|||
RE: Dice probabilities | |||
05-01-2024, 04:26 AM
Post: #28
|
|||
|
|||
RE: Dice probabilities
I've used the programs TO and FRO for the HP-48GX from my older Post #13 to calculate:
TO 5 yx FRO These are the results: [ 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] { 1 5 15 30 45 51 45 30 15 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } [ 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ] { 243 810 1485 1800 1590 1052 530 200 55 10 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } The array is the input and the list is the output of that calculation. |
|||
05-01-2024, 04:41 AM
Post: #29
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 10:00 PM)John Keith Wrote: No real need for Wolfram Alpha, though. On the HP 50 (…)True. But I can't post a link to your HP-50, can I? (04-30-2024 10:00 PM)John Keith Wrote: (…) the Haskell program at A027907 is very fast and easy to implement using DOLIST. Please don't leave us hanging here. Just post your program. |
|||
05-01-2024, 05:54 AM
Post: #30
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 07:30 PM)David Hayden Wrote: I'm lost. What is x? Why do create \(x^2+x^1+x^0\)? How does it relate to the dice? Grant Sanderson does a much better job than me: There's a section starting at 14:40 where he talks about polynomial multiplication. And then following that, one about speeding up with FFTs, which is what I did with the programs for the HP-48GX. |
|||
05-01-2024, 11:14 AM
Post: #31
|
|||
|
|||
RE: Dice probabilities
(04-30-2024 10:07 PM)dm319 Wrote: This is sorcery. Dice = (x^2 + x + 1)/3 With uniform distribution, center has probability of 1/3 Dice^2 = (x^4 + 2x^3 + 3x^2 + 2x + 1)/9 We have triangular distribution. Again, center probability = 3/9 = 1/3 Dice^n, n→∞, will approach normal distribution. Center still has highest probability, but less than 1/3. P(Dice^5, sum=5) < 1/3 = 81/3^5 With x=100, we can numerically evaluate all coefficients of Dice^5 without overlap. (04-29-2024 09:22 PM)Albert Chan Wrote: >10101^5 // (x^2+x+1)^5, for x=100 P(Dice^5, sum=5) = 51/3^5 ≈ 0.2099 Interestingly, this equals P(Dice^5, sum≥7) too. |
|||
05-01-2024, 06:56 PM
Post: #32
|
|||
|
|||
RE: Dice probabilities
(05-01-2024 04:41 AM)Thomas Klemm Wrote:(04-30-2024 10:00 PM)John Keith Wrote: No real need for Wolfram Alpha, though. On the HP 50 (…)True. But I can't post a link to your HP-50, can I? Simpler than I thought using ADD instead of DOLIST. Given n on stack, returns row n of A027907 (2n + 1 coefficients). Code:
For HP48G, use ROT ROT instead of UNROT, also some coefficients will not be exact if n > 27 because they are > 10^12. And now a dumb question: Why can trinomial coefficients be used for any number of dice and faces per die? Are there cases where one may need tetranomial or higher order coefficients? |
|||
05-01-2024, 08:45 PM
(This post was last modified: 05-01-2024 08:49 PM by Thomas Klemm.)
Post: #33
|
|||
|
|||
RE: Dice probabilities
(05-01-2024 06:56 PM)John Keith Wrote: Simpler than I thought using ADD instead of DOLIST. It appears to be similar to my Post #5. (05-01-2024 06:56 PM)John Keith Wrote: And now a dumb question: Why can trinomial coefficients be used for any number of dice and faces per die? Are there cases where one may need tetranomial or higher order coefficients? They can't. Member dm319 initially asked for dice like these: We list their faces as [0 0 1 1 2 2] and encode them as \(2x^2 + 2x + 2\). But since the coefficients are all the same we can use \(x^2 + x + 1\) instead. If however you use one of these: There are multiple possibilities for quadrinomial coefficients:
Or then we rather use \(x^3 + x^2 + x + 1\) to match A008287. Again this doesn't matter much as the coefficients are only shifted. Check in Post #8 how "for extra fun (…) such a formula could be extended to rolling a pool of non-standard, mixed dice". |
|||
05-02-2024, 02:46 PM
(This post was last modified: 05-02-2024 02:51 PM by John Keith.)
Post: #34
|
|||
|
|||
RE: Dice probabilities
(05-01-2024 08:45 PM)Thomas Klemm Wrote:(05-01-2024 06:56 PM)John Keith Wrote: Simpler than I thought using ADD instead of DOLIST. Indeed, and your elegant program can be generalized into a program to produce m-nomial coefficients, which I call MNOM Code:
And a version optimized for the 49 and 50 with ListExt: Code:
Now, typing 6 9 MNOM 14 GET will return your result. |
|||
05-03-2024, 01:20 AM
Post: #35
|
|||
|
|||
RE: Dice probabilities | |||
05-03-2024, 01:08 PM
Post: #36
|
|||
|
|||
RE: Dice probabilities
(05-02-2024 02:46 PM)John Keith Wrote: ... Now, typing 6 9 MNOM 14 GET will return your result. Code: function MNOM(m, n) -- ((x^m-1)/(x-1))^n coefficients lua> pprint(MNOM(3,5)) { 1, 5, 15, 30, 45, 51, 45, 30, 15, 5, 1 } lua> MNOM(6,9)[14] 145899 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)