> On 13 Apr 2022, at 17:46, Raimo Niskanen wrote:
>
> I had an amateur look at a generator as you suggest (multiplier 2^32 and A1 < 2^27), but without xorshift, and it appears to be impossible to achieve decent scores from `spect`.
> It is amazing to see how well a "shitty" generator behaves with xorshift scrambling...
No, wait--I said shitty f₂: I never said "shitty generator". That score identifies a very specific problem of the generator--for the rest, the generator might pass all possible tests. In fact, without the xorshift the generator fails PractRand at 256GB--worse than without xorshift, but definitely _not_ shitty. It would fail with much less data if PractRand had collision tests, but it doesn't.
> So, letting the user mask the low bits from an MWC (or an LCG, for that matter) is the fastest, and reasonably easy to use.
> Forcing the user to do the xorshift is too awkward.
> The 3.8 ns LCG at hand is this one:
> ./spect 1 8 15319397 0x800000000
> 0.674717 0.775734 15319397 0xe9c165 1 0.849147 0.736953 0.779583 0.705774 0.739156 0.679319 0.674717
>
> And I also have a 5.4 ns MCG:
> ./spect 1 8 185852 0x7FFFFFFE1
> 0.650639 0.805885 185852 0x2d5fc 1 0.933056 0.650639 0.801776 0.815666 0.681698 0.772522 0.664310
>
> I have learned that an LCG has e.g got the statistical peculiarity that the lowest bit alternates and then the period doubles for every higher bit, which sounds like an annoying flaw, and that the MCG does not have that flaw, but on the other hand has just less than 35 bits so it is a bit inconvenient to use, and slower.
OK, let's fix the terminology. I might have been taken in previous messages by the fact that x <- mx is a linear map, whereas x <- mx + a is an affine map. What people call LCG are really ACG. What people call MCG (sometimes) are really LCG (but again, some people use LCG for x <- mx).
So let's say that LCG is x <- mx and ACG is x <- mx + a :).
An MWC just simulates an LCG. So mathematically there is no difference between those two generators, and the lower bit of the first will NOT alternate.
> BTW. xorshift up would preserve the peculiar properties of the low bits, right? If so, is xorshift down a tried option?
The shitty spectral score mean that collision tests fail, and collision tests depend on the high bits. xorshifting down doesn't help.
> On 26 Apr 2022, at 21:39, Raimo Niskanen wrote:
>
> So I will have to figure out how to run PractRand, it seems... Is it a better tool than TestU01?
It is complementary. It has a very limited set of sets, but it kills TestU01 in searching for bit patterns. Things that die easily on PractRand pass with flying grades on TestU01.
> Btw. The low 32 bits passed TestU01 BigCrush. Now running high and mid bits.
Yep, but, as I told you, they die horribly on PractRand.
> Regarding MWC vs. the corresponding LCG: my hypothesis is that since they produce the same sequence, they should have the same spectral score for the generators as such, not only for the low MWC "digit". Not important, I guess, since they can be bad even with a good spectral score.
OK, but we're talking about two different things: t, the global state of the generator, is the state of the LCG. We compute spectral scores *on that LCG*. So it's exactly those.
The surprising thing (that happens just because the multiplier is 2^k) is that if the multiplier is 2^-k the k lowest bits of t describe a lattice that is very close to that of the LCG. This can be proved only for the lowest k bits when the multiplier is 2^k. It is not true of any other bit suffix.
I'm running PractRand on the upper 32 bits of your generator and on the "natural" 32 bits of a generator with 58 bits of state and 32-bit digits, xorshifted by << 16. I'm curious to see which method extract more randomness (as measured by PractRand; and I'm already taking as a fact that the lower bit of yours are bad).
> On 26 Apr 2022, at 23:58, Raimo Niskanen wrote:
> By changing the rot58 back to 16 it works much better in PractRand. The high 32 bits (of 58) failed on 256 GB for DC6-9x1Bytes-1. I'll try other bits and again later how rot58 16 works in Test U01...
Interesting!
> On 29 Apr 2022, at 11:25, Raimo Niskanen wrote:
>
> So, XORROT is not bijective, unintuitive, for me that is... Devils in every corner!
Ha ha don't tell me, I discover new ones by the day!
But in some way it's fun--it's like an Easter hunt for eggs.
> Regarding 0x3f3530 vs. 0x7f17555; the larger and better is not slower in my case so I will choose that one.
Perfect. So let's fix our attention on 59 bits of state.
> That all bits might be fine, I guess that would be when rotating over 58 bits as in t ^ (t rotl58 16) (t rotl58 17)?
There's a missing ^ there--is it intensional?
> Could XORROT 16, 32 over 58 bits as in t ^ (t rotl58 16) ^ (t rotl58 32) spread the bits better and also be ok or better?
Yes, that would be very good. As for the amount of shift, I'd take two primes like 11 and 23. But that's just a heuristics, might be uninfluential. The only way to know is to test.
> I have been dabbling with 2*XORSHIFT as in t ^= t << 16; t ^= t << 32 which I suppose also would be bijective, and a bit faster...
If that's faster, let's consider it. Yes, each iteration is bijective and so is the composition. I'd just use lower values (e.g., 8 and 16) so you correct more the lower bits.
I have some, for me, surprising results...
First, using larger xorshifts did not improve the quality of the high bits. Even 10,20 performs worse than 8,16. In fact 6,12 worked better than 10,20 and about as good as 8,16. So I have no better candidate than 8,16, which you suggested from the start...
I'm late in the thread, and probably not understanding it, but this echoes with this article
"Prospecting for Hash Functions" https://nullprogram.com/blog/2018/07/31/
where Chris created a tool to brute force a better hash function
https://github.com/skeeto/hash-prospector
The following best parameters were found recently
https://github.com/skeeto/hash-prospector#discovered-hash-functions
May be the same process can be used for you to find the best
xorshifts parameters for your needs.
--
You received this message because you are subscribed to the Google Groups "prng" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prng+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prng/00b9aaa9-e3b5-4d0e-807c-f5253ac550c2n%40googlegroups.com.
--
Yann Droneaud
OPTEYA