Java generating “random” numbers that don't repeat for 2^48 period

后端 未结 4 1805
萌比男神i
萌比男神i 2021-01-03 03:56

Basically I want to generate random numbers that won\'t ever repeat for a very long period (I don\'t want to use a sequence) like for example the LCG that java uses:

4条回答
  •  一整个雨季
    2021-01-03 04:21

    For reference, the parameters for the linear congruential generator implemented in java.util.Random are as follows:

    a = 25214903917 = 7 x 443 x 739 x 11003
    c = 11
    m = 248
    a – 1 = 25214903916

    The period length is at most m if and only if all of the following are true:

    1. c and m and are relatively prime

    2. a – 1 is divisible by all prime factors of m

    3. a – 1 is a multiple of 4 if m is a multiple of 4

    Yes, the period is 248. The problem is "that the low order bits go through very short cycles." The strong correlation between the low order bits of successive values significantly limits what you can do with them.

提交回复
热议问题