Random number in the range 1 to sys.maxsize is always 1 mod 2^10

后端 未结 3 1265
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 08:55

I am trying to find the statistical properties of the PRNGs available in Python (2.7.10) by using the frequency test, runs test and the chi squared test.

For carryin

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 09:30

    It certainly looks like rounding error in random.sample.

    The bottom 4 or so bits are always zero after the multiplication by the spread of the range (maxsize -1) then when the start of the range (1) is added they are always 1

    if the multiplication was working correctly, given that the spread is not a power of two, and given that the random number only has 53 varying bits I'd expect to see varying values in the rightmost bits too.

提交回复
热议问题