Post Reply 
Calculating odds of rolling a given total with a specified number of dice
06-16-2015, 04:48 PM
Post: #13
RE: Calculating odds of rolling a given total with a specified number of dice
(06-16-2015 03:00 PM)Dave Britten Wrote:  Very interesting stuff. I have to admit, I haven't done anything with FFTs before (though I have a general idea of what they're used for), so this is a bit out of my depth.

This is the relevant Convolution Theorem: [Image: NumberedEquation1.gif]

It's similar to how we avoid the multiplication with: \(\log(a\cdot b) = \log(a) + \log(b)\).

Code:
%%HP: T(3)A(D)F(.);
DIR
  A
[ 3 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 ]
  B
[ 2 1 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 ]
  C
[ 2 1 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 ]
  TO
    \<< FFT 
        OBJ\-> OBJ\-> DROP
        \->LIST
    \>>
  FRO
    \<< OBJ\-> { } + \->ARRY
        IFFT
        OBJ\-> OBJ\-> DROP
        \->LIST
        ABS
        0 RND
    \>>
END

With these two programs you can now run:

A TO 3 yx
B TO x2 ×
C TO ×
FRO

{ 216 540 1314 2393
3618 4880 5774 6112
5878 5116 4022 2886
1870 1080 562 256
98 32 8 1 0 0 0 0 0
0 0 0 0 0 0 0 }


HTH
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Calculating odds of rolling a given total with a specified number of dice - Thomas Klemm - 06-16-2015 04:48 PM



User(s) browsing this thread: 1 Guest(s)