RNG under fire

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brbrbr
    Adept
    • Sep 2015
    • 110

    RNG under fire

    Ok, I've put it to the test.

    Here is the "scientific" research of Angband RNG.
    I've compiled small C program using 4.0.5 code.
    The result is:




    It doesn't like 45-47 numbers and likes number 10, but difference between highest and lowest peaks is less than 0.45%.
    Seems to be fair....

    Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) )
    Last edited by brbrbr; June 27, 2016, 07:54.
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    #2
    Originally posted by brbrbr
    Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) )
    Yesterday I've beaten my infamous spell failure record: I've failed a 1% fail spell four times in a row (was three times before). Hail the mighty RNG!
    PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!

    Comment

    • takkaria
      Veteran
      • Apr 2007
      • 1951

      #3
      Originally posted by brbrbr
      Ok, I've put it to the test.

      Here is the "scientific" research of Angband RNG.
      I've compiled small C program using 4.0.5 code.
      The result is:




      It doesn't like 45-47 numbers and likes number 10, but difference between highest and lowest peaks is less than 0.45%.
      Seems to be fair....

      Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) )
      What do the different coloured lines all mean?
      takkaria whispers something about options. -more-

      Comment

      • Pete Mack
        Prophet
        • Apr 2007
        • 6883

        #4
        mod 100 should be pretty uniform unless the 1 2 or 4 bit is messed up. Each of the bytes in the random number would be more likely to find a bug..but the first 4 bits are the likeliest to be broken. However, statistical streaks of the same value in a row are more interesting. Most RNGs break down here, and have a lower chance of long streaks in the same range. But again, doing it mod 100 will mask any such tendency. For that, you want to do it by division, not mod.

        Comment

        • brbrbr
          Adept
          • Sep 2015
          • 110

          #5
          What do the different coloured lines all mean?
          There were 3 runs with 3 different seeds = different colors.

          Originally posted by Pete Mack
          For that, you want to do it by division, not mod.
          Yeah, andgband code does it by division.

          Comment

          • brbrbr
            Adept
            • Sep 2015
            • 110

            #6
            RESULTS:
            Longest streak of drawing below 5% was 5 in 10000000 tries

            Now, we have to account for monter RNG calls too.
            The way it works, you try to cast a spell (one call to RNG), then monster hit, breathe, hit (three more calls to RNG), then you try to cast again (another RNG)
            So, I modified code to count sequence of every Xth call for RNG.

            Here are more results for X=4:
            Longest streak of drawing every 4th below 5% was 6 in 10000000 tries

            Originally posted by PowerWyrm
            Yesterday I've beaten my infamous spell failure record: I've failed a 1% fail spell four times in a row (was three times before). Hail the mighty RNG!
            Longest streak of drawing every 4th below 1% was 4 in 10000000 tries
            You are absolute winner, PowerWyrm )))))))

            Comment

            • Pete Mack
              Prophet
              • Apr 2007
              • 6883

              #7
              The a priori odds for 5 in a row on a d20 is 3e-7, so in 1e7 tests,
              5 in row is roughly the expected max run length. A stronger test is to find the distribution of all 20 buckets, and compare the run lengths to the corresponding poisson distribution. (Note that you need to use the expected run length of 1/(1-0.5).)

              Originally posted by brbrbr
              RESULTS:
              Longest streak of drawing below 5% was 5 in 10000000 tries

              Now, we have to account for monter RNG calls too.
              The way it works, you try to cast a spell (one call to RNG), then monster hit, breathe, hit (three more calls to RNG), then you try to cast again (another RNG)
              So, I modified code to count sequence of every Xth call for RNG.

              Here are more results for X=4:
              Longest streak of drawing every 4th below 5% was 6 in 10000000 tries


              Longest streak of drawing every 4th below 1% was 4 in 10000000 tries
              You are absolute winner, PowerWyrm )))))))
              Last edited by Pete Mack; June 28, 2016, 02:22.

              Comment

              • brbrbr
                Adept
                • Sep 2015
                • 110

                #8
                Originally posted by Pete Mack
                The a priori odds for 5 in a row on a d20 is 3e-7, so in 1e7 tests,
                5 in row is roughly the expected max run length. A stronger test is to find the distribution of all 20 buckets, and compare the run lengths to the corresponding poisson distribution. (Note that you need to use the expected run length of 1/(1-0.5).)
                Huh!
                Good to know it fits statistical expectation.
                Other buckets are not that interesting, from Angband point of view

                So I satisfied myself and do believe in RNG now. If anyone is still in doubt, send them to me ))

                Comment

                Working...
                😀
                😂
                🥰
                😘
                🤢
                😎
                😞
                😡
                👍
                👎