*
*
Home
Help
Login
Register
Welcome, Guest. Please login or register.
March 05, 2014, 08:56:46 PM

Login with username, password and session length
Forum changes: Editing of posts has been turned off until further notice.
Search:     Advanced search
275647 Posts in 27717 Topics by 4283 Members Latest Member: - otto Most online today: 56 - most online ever: 429 (November 03, 2007, 04:35:43 AM)
Pages: 1 [2]
Print
Author Topic: Exploding dice: Help with calculating averages  (Read 1622 times)
jpegbert
Member

Posts: 8


« Reply #15 on: January 27, 2004, 08:16:55 PM »

My method for mapping 0 to 1 to a die roll was the following:

multiply the randomly generated number by 10^X where X = the number of digits on the die size (so for d4, d6 and d8, X=1 ; for d10 and d12 X=2).  Then I integer divide the result by 1 to truncate the remaining decimal and add 1 to the result.  Then I test to see if the resulting integer value is less than or equal to N, where N is the number of sides on the die.  Can you see anything inherently wrong with this method that might give skewed results?  My programming skills were always half-baked at best.

I'll try the histogram tomorrow.  My results for the d10 and the d12 make me particularly suspicious of my results.  Thanks for all of the time spent, Harlequin.
Logged
Harlequin
Member

Posts: 284


« Reply #16 on: January 27, 2004, 08:58:11 PM »

Hmm.  Certainly I can suggest a better method.  Throwing away all but the lowest 10% of the random number range, then looking for a truly random distribution within that bloc, does strike me as dubious.  If there are any flaws in the randomizer, you'd be almost guaranteed to find them. :)

Try this, very simple, procedure rather than wasting your time on histograms:

A) Multiply random result by N, the die size.
B) Add 0.5 to the result.
C) Round off to the nearest integer.

If the program is handling floats properly and the random range is the normal one (includes zero, does not include one, does include 0.9999), then this should work.

You could also use
A) Multiply by N
B) Round up, to next highest integer
C) If zero, value becomes N

...but I find the first method to be simpler to code, in most cases.  Darn that includes-zero random number standard.  (Interesting to envision a d8 with that physical property... one in a million or so rolls, what would have been an eight becomes a zero.  Puzzled gamer inspects die, finds the other seven sides correct.  Rolls it again, the eight is back, for a million or so more rolls.)

Try that, and see if your results come closer to the algebraic solution.

- Eric

PS: No problem.  My inner math geek likes to play.  You can pay me back by making Ken Burnside happy and convincing someone to buy Attack Vector.  I get no money, but happy Ken is fun to watch and I'd consider myself well thanked.
Logged
cthulahoops
Member

Posts: 45


WWW
« Reply #17 on: January 28, 2004, 02:25:53 AM »

Hi,

I thought it might be helpful to see if I can generate the algebraic results numerically.  I can.

explode.c produces the appropriate results.

Adam.
Logged

Jack Aidley
Member

Posts: 488


WWW
« Reply #18 on: January 28, 2004, 02:37:00 AM »

With most random number generators the high bits give a more random result than the low bits. The rand function in most languages is pretty poor anyway, so it will tend to produce bad results for stuff like this.

Harelquin's method above is the best to use if you must.
Logged

- Jack Aidley, Great Ork Gods, Iron Game Chef (Fantasy): Chanter
Jack Aidley
Member

Posts: 488


WWW
« Reply #19 on: January 29, 2004, 07:44:59 AM »

Thinking about it, I think calculating the average of an exploding die is going to be singular useless. More useful is working out how likely you are to hit certain target numbers.

It turns out to pretty easy to figure your odds of hitting a given target number n:

Let x be the number sides on your dice.
Let d be the interger value of n/x (i.e 5 for n = 33 and x = 6)
Let r be the remainder of the above sum.

( ^ here means to the power of)

Then:

if r = 0 p(n) = 1/x^d
if r != 0 p(n) = (x - r + 1)/( x^(d+1) )

Hope those equasions aren't too unclear.
Logged

- Jack Aidley, Great Ork Gods, Iron Game Chef (Fantasy): Chanter
Pages: 1 [2]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Oxygen design by Bloc
Valid XHTML 1.0! Valid CSS!