commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Herbert <alex.d.herb...@gmail.com>
Subject Re: [Rng] New XoShiRo generators
Date Wed, 06 Mar 2019 23:26:58 GMT


> On 6 Mar 2019, at 22:57, Gilles Sadowski <gilleseran@gmail.com> wrote:
> 
>>> 
>>> However I will test if XorShift1024Star and XorShift1024StarPhi are correlated
just for completeness.
>>> 
>> 
>> Did a test of 100 repeats of a correlation of 50 longs from the XorShift1024Star
and XorShift1024StarPhi, new seed each time:
>> 
>> SummaryStatistics:
>> n: 100
>> min: -0.30893547071559685
>> max: 0.37616626218398586
>> sum: 3.300079237520435
>> mean: 0.033000792375204355
>> geometric mean: NaN
>> variance: 0.022258533475114764
>> population variance: 0.022035948140363616
>> second moment: 2.2035948140363617
>> sum of squares: 2.312500043775496
>> standard deviation: 0.14919294043323486
>> sum of logs: NaN
>> 
>> Note that the algorithm is the same except the final step when the multiplier is
used to scale the final output long:
>> 
>>   return state[index] * multiplier;
>> 
>> So if it was outputting a double the correlation would be 1. But it is a long generator
so the long arithmetic wraps to negative on large multiplications. The result is that the
mean correlation is close to 0.
>> 
>> A single repeat using 1,000,000 numbers has a correlation of 0.002.
>> 
>> Am I missing something here with this type of test?
> 
> I'm afraid I don't follow: If the state is the same then I'd assume that
> the two generators are the same (i.e. totally correlated).
> 

The state is totally correlated (it is identical). The output sequence is not due to wrapping
in long arithmetic. Here’s a mock example:

positive number * medium positive number = big positive number (close to Long.MAX_VALUE)

Vs

positive number * bigger positive number = negative number (due to wrapping)

So by changing the multiplier this wrapping causes the output bits to be different. This is
why the new variant "eliminates linear dependencies from one of the lowest bits” (quoted
from the authors c code).

The multiplier was changed from 1181783497276652981L to 0x9e3779b97f4a7c13L. These numbers
are big:

Long.MAX_VALUE / 1181783497276652981L = 7.8046207770792755
Long.MAX_VALUE / 0x9e3779b97f4a7c13L = -1.3090169943749475

Big enough such that wrapping will occur on every multiplication unless the positive number
is <8, or now <2. So basically all the time.

So, IIUC, the output is thus a truncated product formed by the wrapping long arithmetic and
not correlated.





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message