Thanks but not so well x) , it's getting better hopefullytorne wrote: Sun May 25, 2025 1:24 pm Yes, this is what I meant, and it seems like you understand that part pretty well from your own research now.
%8 is fine though here, because 8 is a power of two: it's 2^3, and so divides evenly into our original 32-bit random value. But, yeah, if we want a value between 0 and 9, just using %10 is going to be slightly more likely to generate 0-5 and slightly less likely to generate 6-9.


That clarify things somehow x). Because when i was doing research for the RNG, it was mentionned the period of repetition, with the >> << xor method, states of bits can and will repeat after some very long period of time, unless if the number are not choosen properly, the repetition can occur much faster than expected. So i knew there were "more complicated things", already. But if you say "pretty-much infinite numbers of ways", that make sense to me intuitively to put it in the "extremely complicated things". It clarify the pointlessness of the quest of searching for "the" test.torne wrote: Sun May 25, 2025 1:24 pm You are correct that just testing how often each value occurs doesn't tell you that it is really random, but if the values *don't* occur equally often then it's definitely *not* a uniform random distribution - having them occur equally often is necessary but not sufficient. Correlations between the values in a supposedly-random sequence, as you say, is another important property, and this is where things get extremely complicated, because there's a pretty-much infinite number of possible ways that the values might be correlated with each other, and therefore also a pretty-much infinite number of tests we could try.
I think i understand the idea, i can imagine it's an area of expertise on its own, i know when i try to follow links in article that i quickly reach a point where i understand nothing x).torne wrote: Sun May 25, 2025 1:24 pm Your example here suggests one simple test: we could take the *difference* between consecutive values in the sequence and see if the differences look uniformly distributed. The "x+1 => x" generator would fail this test very quickly, since the difference would always be 1 - we wouldn't need much data to conclude that there's a correlation. But, other generators might pass this test but still fail other more complex tests. Which tests are most useful is a whole complex area of math that's beyond my expertise - I'm just a computer scientist, not a mathematician
But for this particular example, if the number are randomly choosen, ( just a 'gambler' intuition ) , i don't think their *differences* would be uniformly distributed, i think it could be "on average" 50% smaller if you start with a number from the middle of the range and you pick a 2nd number. Or if you start with a number near a bound of the range and then a second number. Sounds like the expected distribution would be an inverse bell, with 50% as the range on the side and 25% of the range in the middle ?
I think the main idea i get is one need to compare the pseudo-RNG and a true random sequence, to compare their properties , their *difference* should have the same distribution. Which wouldn't be 1 1 1 1 x). But that it would be just 1 another test amongst "many".
Good thing i goofed around with the parameter from the wikipedia page then, maybe it work less well for the quality of the randomness but my Linear shift back register has not a well known parameter x)torne wrote: Sun May 25, 2025 1:24 pm There's also a separate property here that's important for security/cryptography/other cases where you have an adversary, though, which is "given some numbers from the random sequence, how easy is it to predict future values in the sequence". The LCG discussed here is terrible at this: if we know the specific parameters being used (the multiplicand and addend) then all we need to know is any one value from the sequence, and then we can predict *all* future values perfectly. And, since the algorithm here is a common, standard one, and the parameters used are well-known ones, we can easily guess all of this: if we have two values from the sequence, we can very quickly try a bunch of different common PRNG algorithms/parameters and see if any of them do in fact turn the first value into the second value.
This is beyond my imagination to think of something that wouldn't let you know the future value of the sequence if you know the parameters. It's like "seeded RNG" in the case of the linear shift back register i attached, so if you know the seed and the parameter, it will always follow the same sequence, and from a number and the parameter it's also possible to do so.
I can see how a RNG made in factorio that would rely on the method eugenekay posted would be achieving such result that with just the first few number , it would remain a mystery which will be the next, but when it comes to thinking about how it works for the game to pick those numbers in the first place it's different than when the pseudo randomness comes only from combinator operations. It doesn't require any seed and as such for my music purposes i couldn't use it , because i wanted to be able to know the sequence in advance, that was the reverse of cryptography x).
I wanted to make sure it would be "random" but also always the same with the same seed, so when i changed the machine i could hear the difference based on my change and not based on a different random sequence when the machine was copy pasted. That's where i see the other method different, if used to choose receipe or train stop, it can and will choose a different "first one " everytime ! ( not sure it's 100% related with what you said though ) but i feel it's important in the context of actually using those in practice !