[
https://issues.apache.org/jira/browse/RNG-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16855630#comment-16855630
]
Alex D Herbert commented on RNG-75:
-----------------------------------
Here are the results of the generator from the SeedFactory:
{code:java}
Well44497b well44497b = ...;
well44497b.nextInt() ^ System.identityHashCode(new Object())
{code}
Stress test results:
{noformat}
RNG Dieharder TestU01 (BigCrush)
WELL_44497_B 0,0,0,0,0 2,3,2,2,2
WELL_44497_B + HashCode 0,0,0,0,0 2,2,3,3,2
{noformat}
So mixing with the identity hash code is not making the output stronger.
Here are the failed tests from the plain generator:
{noformat}
RandomSource,Bit-reversed,Test,Failures,Failed
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),3,11 CollisionOver, t = 21|80
LinearComp, r = 0|81 LinearComp, r = 29
{noformat}
And the combined generator:
{noformat}
RandomSource,Bit-reversed,Test,Failures,Failed
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),2,80 LinearComp, r = 0|81 LinearComp, r
= 29
WELL_44497_B,false,TestU01 (BigCrush),3,10 CollisionOver, t = 14|80
LinearComp, r = 0|81 LinearComp, r = 29
WELL_44497_B,false,TestU01 (BigCrush),3,5 CollisionOver, t = 3|80 LinearComp,
r = 0|81 LinearComp, r = 29
{noformat}
So it is still failing the same tests.
Note that:
{noformat}
"The parameter r gives the number of bits that are discarded from each
generated random number. That is, each real-valued random number is multiplied
by 2r
modulo 1, to drop its r most significant bits."
{noformat}
So this is failing Linear Complexity test with all bits (r=0) and only the 3
lower bits (r=29).
A quick check of values from System.identityHashCode(new Object()) shows that
it never outputs a negative value. Here is the histogram of the number of times
each bit is set from 10000:
{noformat}
0 5000
1 5069
2 4997
3 5008
4 4947
5 5011
6 4983
7 5000
8 4983
9 4955
10 5114
11 4982
12 5042
13 5063
14 4941
15 4986
16 4990
17 5132
18 4962
19 4943
20 4995
21 5078
22 4970
23 4969
24 4962
25 5005
26 4991
27 4980
28 4955
29 4980
30 5054
31 0
{noformat}
It does use all the other bits evenly. Lack of a bit in position 31 would
explain the failure of Linear Comp for r=0, but the failure of r=29 is due to
the low complexity of the lower 3 bits of both Well44497b and the hash code
combined.
> Improve the speed of the RandomSource create method.
> ----------------------------------------------------
>
> Key: RNG-75
> URL: https://issues.apache.org/jira/browse/RNG-75
> Project: Commons RNG
> Issue Type: Improvement
> Components: simple
> Affects Versions: 1.3
> Reporter: Alex D Herbert
> Assignee: Alex D Herbert
> Priority: Minor
> Fix For: 1.3
>
> Attachments: large.jpg, long.jpg, small.jpg
>
>
> Update the {{o.a.c.rng.simple.internal}} package to improve the construction
> speed of random generators.
> Areas identified by the construction benchmark
> [RNG-72|https://issues.apache.org/jira/projects/RNG/issues/RNG-72] include:
> * Update the {{RandomSourceInternal}} to know the desired size for the native
> seed
> * Update the {{SeedFactory}} for faster {{byte[]}} conversions
> * Remove the use of reflection for fast seeding generators
> It is intended that all changes made are non-destructive to the quality of
> any generated seed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)