1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. While the majority of active discourse on D20PRO has moved to our Discord Channels, this forum is still active and checked-in on regularly by our staff. However, for the very latest information, conversation and/or immediate support, please join us on Discord here: http://discord.gg/Ph38ckM
    Dismiss Notice

Dice rolling results - gaussian instead of normal?

Discussion in 'Bug Reports & Installation Support' started by Lokasenna, Aug 15, 2016.

  1. Lokasenna

    Lokasenna New Member

    Joined:
    Dec 8, 2015
    Messages:
    11
    Likes Received:
    0
    Is this already a known issue? Dice rolling does not follow an even distribution, but a "bell" curve/gaussian distribution. Admittedly, the links I am about to share are not to my own research as I could not recall my Excel lessons to make pretty little graphs, but a manual count of my own testing (I have attached the 1000d8 rolls) bears it out.

    10000 d2, d3, and d6's: http://i.imgur.com/nZjLjTS.png
    100000d20: http://i.imgur.com/Uwrakhl.png
    Raw roll data: https://drive.google.com/open?id=0BzS6i2JCDwdtQ3RqbmdnUEw4SHM

    Obviously, this can have extreme effects on games as the typical ruleset is designed with an even distribution on the dice rolling, not a normal distribution. This means critical hits are far less likely, critical failures are less likely (although more likely than critical successes).

    For example, in the attached .csv, you can see that there are:
    88x 1's
    132x 2's
    164x 3's
    190x 4's
    171x 5's
    155x 6's
    65x 7's
    35x 8's

    There should be 125x of each result in an even distribution with 1000 rolls. Ack!

    Since it happens with all dice, it should be fairly easy to track down... but I imagine not so easy to fix if it involves the code library itself. That said, it NEEDS to be fixed. Knowing this is an issue jeopardizes the use of d20pro as a complete tabletop simulation tool, IMO, because it means I/we need to find external solutions for dice rolling.
     

    Attached Files:

  2. edwardcd

    edwardcd Administrator
    Staff Member

    Joined:
    Oct 13, 2010
    Messages:
    1,374
    Likes Received:
    9
    We will take another look at this, as we are using a combination of a few random number generators to try to mitigate the Gaussian generation.
    SecureRandom and MersenneTwisterRNG.

    Here is what I got, which confirms your assessment.

    Die Roll - Frequency - Percentage
    1 - 804 - 8.04%
    2 - 1298 - 12.98%
    3 - 1663 - 16.63%
    4 - 1882 - 18.82%
    5 - 1714 - 17.14%
    6 - 1337 - 13.37%
    7 - 826 - 8.26%
    8 - 476 - 4.76%
    Total 10,000
     
  3. owlbear

    owlbear Administrator
    Staff Member

    Joined:
    Sep 5, 2011
    Messages:
    636
    Likes Received:
    160
    Indeed the base roll is Gaussian, this is largely due to the need to make Java's RND not spit out the same digit when rolled sequentially. That being said, this is adjustable. here's my thought, and please give feedback, I can expose the randomizers on the GM side in the options panel allowing for settings to be controlled per campaign.

    Basically, I can add some options to allow you to enable Base Gaussian, SecureRandom, Seed value and Toggle MersenneTwisterRNG.

    When we were gauging the results of the new algorithm, we used both actual die rolls and the hefty research over at anydice.com for guidance.

    Again, we certainly welcome feedback and suggestions here.
     
  4. Lokasenna

    Lokasenna New Member

    Joined:
    Dec 8, 2015
    Messages:
    11
    Likes Received:
    0
    It's great to know that this is being worked on. I know (mostly from hearsay) that Java's capabilities in generating randoms are not as great as other languages. Until the distribution is more towards an even end, I think I may simply modify things in the ruleset to account for the different probabilities (like critical threat ranges).

    In any case, for suggestions... the options you mention - would any of them alleviate the problem? Even a less pronounced "bell" curve would be an improvement.

    It has been years (I think a decade, actually) since I did anything with Java and so I'm sure that my initial Googling for ways to get a uniform distribution via Java randoms is only coming up with things you've tried already (or eliminated due to difficulty of implementation in already existing software).
     
  5. owlbear

    owlbear Administrator
    Staff Member

    Joined:
    Sep 5, 2011
    Messages:
    636
    Likes Received:
    160
    The library we injected/implemented to handle distribution maths is linked here.

    The current equation is to do an initial roll using a gaussian RND then process it using a MersenneTwisterRNG (if I recall correctly, don't have the code in front of me atm).

    employing any of the listed distribution wrappers is very easy now that uncommon-maths-lib is integrated into the system.

    [fixed] so the problem was two fold. The gaussian distribution was being processed after the initial generation -- sigh. The second problem was the SecureRandom seed generator wasn't really doing a lot to introduce variance.

    I've updated this to use a built in seed generator from Uncommons which will use the best available source based on the detected operating system. [note] this might result in skewed results across platforms, but should actually results in a more uniform solution.

    The second is that I replaced the Gaussian bit entirely with the updated DiscreteUniformGenerator. This should give much better results.

    I'll be pushing out the service update as a beta first (with a two - three day life span). Once this goes live, I'd love to have you take a look at the results.
     
  6. Lokasenna

    Lokasenna New Member

    Joined:
    Dec 8, 2015
    Messages:
    11
    Likes Received:
    0
    Wonderful news - can't wait!

    Interesting bit of info there about the detected OS. If one were to have a "poor" source in their OS, is this something that could be addressed by the user obtaining a better set of libraries?
     
  7. edwardcd

    edwardcd Administrator
    Staff Member

    Joined:
    Oct 13, 2010
    Messages:
    1,374
    Likes Received:
    9
    Hi Lokasenna,

    I've re-tested the randomness of the updated beta (v3.6.7.7 beta) and here are the results, using 10,000 rolls.

    D8
    dieRollsNew.jpg

    D20
    D20_dieRollsNew.jpg
     
  8. Lokasenna

    Lokasenna New Member

    Joined:
    Dec 8, 2015
    Messages:
    11
    Likes Received:
    0
  9. owlbear

    owlbear Administrator
    Staff Member

    Joined:
    Sep 5, 2011
    Messages:
    636
    Likes Received:
    160
    yay! you guys like it -- heh
     
  10. Mickey

    Mickey Member

    Joined:
    Jun 19, 2015
    Messages:
    70
    Likes Received:
    4
    That's brilliant! Nice to have truly random rolls now. Well done.
     
  11. Tay-Dor

    Tay-Dor Active Member

    Joined:
    May 15, 2016
    Messages:
    313
    Likes Received:
    47
  12. owlbear

    owlbear Administrator
    Staff Member

    Joined:
    Sep 5, 2011
    Messages:
    636
    Likes Received:
    160
    Regarding the "better set of libraries" -- no longer an issues. using the new method we're creating a consistent key with a few fall back options in that one fails an integrity check.
     

Share This Page