[前:SplitMix64について]   [ExRand目次]   [次:SplitMix64とXorshiftを組み合わせる(高機能版)]

[QNC]SplitMix64とXorshiftを組み合わせる

目次

[QNC]SplitMix64とXorshiftを組み合わせる

SplitMix64 は周期が2⁶⁴と短く、PractRandで検定すると失敗します。
そこで SplitMix64 と Xorshift を組み合わせた qnc.h を開発しました。
これは速度をできるだけ遅くせずに、周期を2⁷⁰⁴-2⁶⁴と長くしたものです。

多くのコンパイラでコンパイル可能です。

define.h はこちら

QncRandをtestU01で検定する

QnxRand は QncRand をより一般化した疑似乱数です。
10U は QnxRand を QncRand と同じにするパラメータです。
まず testU01 で検定した結果の要約を示します。
type                     , c, test                    , p-value
QnxRand 10U rawhi Seed(1), B, Passed                  , -      
QnxRand 10U rawhi Seed(2), B, Passed                  , -      
QnxRand 10U rawhi Seed(3), B, RandomWalk1 M(L=50,r=25), 6.9e-4 
QnxRand 10U rawhi Seed(4), B, Passed                  , -      
QnxRand 10U rawhi Seed(5), B, Passed                  , -      
QnxRand 10U rawhi Seed(6), B, Passed                  , -      
QnxRand 10U rawlo Seed(1), B, Passed                  , -      
QnxRand 10U rawlo Seed(2), B, Passed                  , -      
QnxRand 10U rawlo Seed(3), B, MatrixRank,L=1000,r=0   , 0.9995 
QnxRand 10U rawlo Seed(4), B, Passed                  , -      
QnxRand 10U rawlo Seed(5), B, Passed                  , -      
QnxRand 10U rawlo Seed(6), B, ClosePairs mNP2,t=5     , 8.3e-4 
QnxRand 10U revhi Seed(1), B, Passed                  , -      
QnxRand 10U revhi Seed(2), B, Passed                  , -      
QnxRand 10U revhi Seed(3), B, Passed                  , -      
QnxRand 10U revhi Seed(4), B, CollisionOver,t=21      , 6.0e-4 
-                        , B, AppearanceSpacings,r=27 , 2.4e-4 
QnxRand 10U revhi Seed(5), B, MatrixRank,L=30,r=0     , 9.1e-4 
-                        , B, LempelZiv,r=15          , 3.9e-4 
QnxRand 10U revhi Seed(6), B, Passed                  , -      
QnxRand 10U revlo Seed(1), B, Passed                  , -      
QnxRand 10U revlo Seed(2), B, Passed                  , -      
QnxRand 10U revlo Seed(3), B, Passed                  , -      
QnxRand 10U revlo Seed(4), B, Passed                  , -      
QnxRand 10U revlo Seed(5), B, HammingCorr,L=1200      , 4.5e-4 
QnxRand 10U revlo Seed(6), B, Passed                  , -      
QnxRand 10U swphi Seed(1), B, WeightDistrib,r=28      , 9.8e-4 
QnxRand 10U swphi Seed(2), B, Passed                  , -      
QnxRand 10U swphi Seed(3), B, CollisionOver,t=3       , 0.9994 
QnxRand 10U swphi Seed(4), B, Passed                  , -      
QnxRand 10U swphi Seed(5), B, CollisionOver,t=21      , 9.4e-4 
QnxRand 10U swphi Seed(6), B, Passed                  , -      
QnxRand 10U swplo Seed(1), B, Passed                  , -      
QnxRand 10U swplo Seed(2), B, Passed                  , -      
QnxRand 10U swplo Seed(3), B, Passed                  , -      
QnxRand 10U swplo Seed(4), B, Passed                  , -      
QnxRand 10U swplo Seed(5), B, Passed                  , -      
QnxRand 10U swplo Seed(6), B, MaxOft AD,t=8           , 3.9e-4 
-                        , B, Savir2                  , 0.9997 
このように rdrand とほぼ同じ品質であることがわかります。

QncRandをPractRandで検定する

次に PractRand での検定です。
以下の6つの検定をしました。
(1)RNG_test stdin64 -tlmin 1GB -multithreaded
(2)RNG_test stdin64 -tlmin 1GB -tf 2 -multithreaded
(3)RNG_test stdin64 -tlmin 1GB -te 1 -tlmax 8TB -multithreaded
(4)RNG_test stdin64 -tlmin 1GB -te 1 -tf 2 -tlmax 8TB -multithreaded
(5)RNG_test stdin64 -tlmin 1GB -te 10 -tlmax 8TB -multithreaded
(6)RNG_test stdin64 -tlmin 1GB -te 10 -tf 2 -tlmax 8TB -multithreaded
本来は -te 1 や -te 10 でも既定の 32TB まで検定したかったのですが、
-te 0 に比べて時間がかかるので 8TB までにしました。
(1),(3),(4),(5)は、種1で異常はありませんでした。
(2)RNG_test stdin64 -tlmin 1GB -tf 2 -multithreadedは、種1で、
length= 16 terabytes (2^44 bytes), time= 59966 seconds
  Test Name                         Raw       Processed     Evaluation
  [Low8/32]BCFN(2+1,13-0,T)         R=  -8.3  p =1-2.4e-4   unusual          

length= 32 terabytes (2^45 bytes), time= 121080 seconds
  Test Name                         Raw       Processed     Evaluation
  [Low8/32]Gap-16:B                 R=  +5.7  p =  9.2e-5   unusual          

となりましたが、種2で、1GB から 32TB まで異常はありませんでした。

(6)RNG_test stdin64 -tlmin 1GB -te 10 -tf 2 -tlmax 8TB -multithreaded
を種1で検定すると
length= 8 gigabytes (2^33 bytes), time= 135 seconds
  Test Name                         Raw       Processed     Evaluation
  [Low8/32]BDayS128(26):all2        R=  +5.2  p~=   1e-7    very suspicious  

length= 16 gigabytes (2^34 bytes), time= 243 seconds
  Test Name                         Raw       Processed     Evaluation
  [Low8/32]BDayS128(26):all1        R=  +3.5  p~=   1e-3    unusual          
  [Low8/32]BDayS128(26):all2        R=  +4.2  p~=   1e-5    suspicious       

length= 32 gigabytes (2^35 bytes), time= 452 seconds
  Test Name                         Raw       Processed     Evaluation
  [Low4/32]BDayS128(26):all2        R=  +2.8  p~=   2e-3    unusual          

でしたが、種8で、1GB から 8TB まで異常はありませんでした。
PractRandでQncRandを種を1~40にして 1GB, 2GB, 4GB の3つの長さで、 異常のあったものを表示します。
120回分を1つのテストとします。
te0, te1, te10 と tf1, tf2 の6個の組み合わせをテストして合計720回調べました。

QnxRand 10U te0 tf1 Seed(4) 1GB  [Low16/64]Gap-16:A p=1-6.9e-4 unusual 
QnxRand 10U te0 tf1 Seed(4) 1GB  [Low4/64]BRank(12):384(1) p=1.8e-5 unusual 
QnxRand 10U te0 tf1 Seed(4) 2GB  [Low4/64]BRank(12):384(1) p=1.8e-5 unusual 
QnxRand 10U te0 tf1 Seed(4) 4GB  [Low4/64]BRank(12):384(1) p=1.8e-5 unusual 
QnxRand 10U te0 tf1 Seed(7) 4GB  [Low1/64]FPF-14+6/16:all p=1-1.0e-4 unusual 
QnxRand 10U te0 tf1 Seed(12) 2GB  DC6-9x1Bytes-1 p=8.1e-4 unusual 
QnxRand 10U te0 tf1 Seed(21) 2GB  [Low1/64]Gap-16:B p=8.0e-4 unusual 
QnxRand 10U te0 tf1 Seed(24) 1GB  [Low1/64]Gap-16:A p=2.8e-4 unusual 
QnxRand 10U te0 tf1 Seed(37) 1GB  [Low1/64]DC6-9x1Bytes-1 p=1-2.7e-3 unusual 
QnxRand 10U te0 tf1 Seed(37) 2GB  [Low1/64]DC6-9x1Bytes-1 p=1-2.5e-3 unusual 
QnxRand 10U te0 tf1 Seed(39) 2GB  [Low1/64]Gap-16:A p=9.5e-4 unusual 
QnxRand 10U te0 tf2 Seed(4) 1GB  [Low1/8]BCFN(2+1,13-3,T) p=1-2.7e-4 unusual 
QnxRand 10U te0 tf2 Seed(7) 4GB  [Low1/64]FPF-14+6/16:all p=1-1.0e-4 unusual 
QnxRand 10U te0 tf2 Seed(12) 2GB  DC6-9x1Bytes-1 p=8.1e-4 unusual 
QnxRand 10U te0 tf2 Seed(15) 1GB  [Low1/32]Gap-16:A p=1-1.4e-4 unusual 
QnxRand 10U te0 tf2 Seed(23) 2GB  [Low1/16]DC6-9x1Bytes-1 p=7.0e-4 unusual 
QnxRand 10U te0 tf2 Seed(24) 1GB  [Low1/64]Gap-16:A p=2.8e-4 unusual 
QnxRand 10U te0 tf2 Seed(28) 2GB  [Low1/32]DC6-9x1Bytes-1 p=1-5.6e-4 unusual 
QnxRand 10U te1 tf1 Seed(7) 4GB  [Low1/64]FPF-14+6/16:all p=1-1.0e-4 unusual 
QnxRand 10U te1 tf1 Seed(12) 2GB  DC7-9x1Bytes-1:both p=8.1e-4 unusual 
QnxRand 10U te1 tf1 Seed(24) 1GB  [Low1/64]Gap-16:A p=2.8e-4 unusual 
QnxRand 10U te1 tf1 Seed(30) 2GB  FPF-14+6/4:cross p=1-8.3e-5 unusual 
QnxRand 10U te1 tf2 Seed(8) 1GB  [Low4/16]DC7-6x2Bytes-1:both p=1-2.7e-4 unusual 
QnxRand 10U te1 tf2 Seed(29) 4GB  [Low1/8]DC7-5x4Bytes-1:even p=3.2e-5 unusual 
QnxRand 10U te10 tf1 Seed(4) 4GB  [Low1/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf1 Seed(6) 1GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf1 Seed(9) 1GB  [Low1/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf1 Seed(29) 1GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf1 Seed(31) 4GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(4) 4GB  [Low1/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(4) 4GB  [Low4/16]BDayS128(26):all1 p=3e-4 unusual 
QnxRand 10U te10 tf2 Seed(4) 4GB  [Low4/16]BDayS128(26):all2 p=6e-18 FAIL ! 
QnxRand 10U te10 tf2 Seed(5) 1GB  [Low4/32]BDayS128(26):inc1 p=2e-3 unusual 
QnxRand 10U te10 tf2 Seed(5) 1GB  [Low4/32]BDayS128(26):inc2 p=9e-12 FAIL 
QnxRand 10U te10 tf2 Seed(6) 1GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(9) 1GB  [Low1/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(12) 2GB  [Low8/32]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(13) 1GB  [Low8/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(13) 4GB  [Low4/32]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(13) 4GB  [Low8/32]BDayS128(26):all2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(15) 2GB  [Low8/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(17) 2GB  [Low1/16]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(19) 2GB  [Low1/8]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(25) 4GB  [Low1/16]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(27) 4GB  [Low8/64]BDayS128(26):inc1 p=3e-4 unusual 
QnxRand 10U te10 tf2 Seed(27) 4GB  [Low8/64]BDayS128(26):inc2 p=6e-18 FAIL ! 
QnxRand 10U te10 tf2 Seed(29) 1GB  [Low1/8]BDayS128(26):inc1 p=2e-3 unusual 
QnxRand 10U te10 tf2 Seed(29) 1GB  [Low1/8]BDayS128(26):inc2 p=9e-12 FAIL 
QnxRand 10U te10 tf2 Seed(29) 1GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(31) 4GB  [Low4/64]BDayS128(26):inc2 p=8e-6 suspicious 
QnxRand 10U te10 tf2 Seed(36) 1GB  [Low4/32]BDayS128(26):inc1 p=2e-3 unusual 
QnxRand 10U te10 tf2 Seed(36) 1GB  [Low4/32]BDayS128(26):inc2 p=9e-12 FAIL 
QnxRand 10U te10 tf2 Seed(39) 4GB  [Low1/16]BDayS128(26):inc2 p=8e-6 suspicious 
te10 で suspicious や FAIL が出現しますが、
rdrandをtestU01とPractRandで検定するの 結論より問題ありません。
他の場合でも rdrand とほぼ同じ品質であることがわかります。

[QSC]組込み関数を使ったSSE2バージョン

gcc, clang, vc2002 .. vc2022 でコンパイル可能です。

define.h, bincode.h はこちら bincode.h は Visual C++2002 と Visual C++ 2003 でのみ必要です。

[QSB]機械語を使ったSSE2バージョン

多くのコンパイラでコンパイル可能です。

define.h, bincode.h はこちら

[QAC]組込み関数を使ったAVX2バージョン

gcc, clang, VC++2013.. VC++2022 でコンパイル可能です。

define.h はこちら

[QAB]機械語を使ったAVX2バージョン

多くのコンパイラでコンパイル可能です。

define.h, bincode.h はこちら

[QBC]組込み関数を使ったAVX512バージョン

gcc, clang, VC++2017 .. VC++2022 でコンパイル可能です。

define.h はこちら

[QBB]機械語を使ったAVX512バージョン

多くのコンパイラでコンパイル可能です。

define.h, bincode.h はこちら

[前:SplitMix64について]   [ExRand目次]   [次:SplitMix64とXorshiftを組み合わせる(高機能版)]