2015-10-05 203 views
6

我有幾個包含大量由各種RNG生成的整數(大約250萬)的.txt文件。我想用死硬的測試套件來測試這些RNG。使用包含隨機數的.txt文件和diehard測試套件

的.txt文件是這樣的:

#============================================== 
# generator Park  seed = 1 
#============================================= 
type: d 
count: 2500000 
numbit: 32 
16807 
282475249 

其次是ofcourse,多個整數。我用下面的命令來運行這個死忠.txt文件

dieharder -f randdata.txt -a - g 202 

我的問題是,是我的.txt文件正確(特別是前幾行),以及爲什麼這些線路neccesary?我問這個問題的原因是因爲每個由某些RNG生成的.txt文件(一些好的,一些壞的)幾乎無法通過每個測試,我想知道這是否是因爲我在傳遞.txt文件時發生了一些錯誤,或者如果我的RNG都很糟糕。

回答

8

是的,那個輸入文件看起來是正確的。這似乎是一個數量dieharder測試失敗,甚至與dieharder自己發生器產生10M輸入:

$ dieharder -o -f example.input -t 10000000 # Generate an input file 
$ head -n 10 example.input 
#================================================================== 
# generator mt19937 seed = 3423143424 
#================================================================== 
type: d 
count: 10000000 
numbit: 32 
2310531048 
808929469 
2423056114 
4237891648 
$ dieharder -a -g 202 -f example.input 
#=============================================================================# 
#   dieharder version 3.31.1 Copyright 2003 Robert G. Brown   # 
#=============================================================================# 
    rng_name |   filename    |rands/second| 
    file_input|     example.input| 2.50e+06 | 
#=============================================================================# 
     test_name |ntup| tsamples |psamples| p-value |Assessment 
#=============================================================================# 
# The file file_input was rewound 1 times 
    diehard_birthdays| 0|  100|  100|0.07531570| PASSED 
# The file file_input was rewound 11 times 
     diehard_operm5| 0| 1000000|  100|0.00000000| FAILED 
# The file file_input was rewound 24 times 
    diehard_rank_32x32| 0|  40000|  100|0.00047786| WEAK 
# The file file_input was rewound 30 times 
    diehard_rank_6x8| 0| 100000|  100|0.38082242| PASSED 
# The file file_input was rewound 32 times 
    diehard_bitstream| 0| 2097152|  100|0.56232583| PASSED 
# The file file_input was rewound 53 times 
     diehard_opso| 0| 2097152|  100|0.83072458| PASSED 

我不知道究竟你有多少樣本需要得到「更好」的結果...但失敗教訓只有250萬的數字看起來像他們預計。

一些試驗後,雖然,這似乎是試驗開始用〜隨機二進制數據的120MB傳遞:

 
$ dd if=/dev/urandom of=/tmp/random bs=4096 count=30000 
30000+0 records in 
30000+0 records out 
122880000 bytes transferred in 10.873818 secs (11300538 bytes/sec) 
$ du -sh /tmp/random 
117M /tmp/random 
$ dieharder -a -g 201 -f /tmp/random 
#=============================================================================# 
#   dieharder version 3.31.1 Copyright 2003 Robert G. Brown   # 
#=============================================================================# 
    rng_name |   filename    |rands/second| 
file_input_raw|      /tmp/random| 1.11e+07 | 
#=============================================================================# 
     test_name |ntup| tsamples |psamples| p-value |Assessment 
#=============================================================================# 
    diehard_birthdays| 0|  100|  100|0.71230346| PASSED 
# The file file_input_raw was rewound 3 times 
     diehard_operm5| 0| 1000000|  100|0.62093817| PASSED 
# The file file_input_raw was rewound 7 times 
    diehard_rank_32x32| 0|  40000|  100|0.02228171| PASSED 
# The file file_input_raw was rewound 9 times 
    diehard_rank_6x8| 0| 100000|  100|0.20698623| PASSED 
# The file file_input_raw was rewound 10 times 
    diehard_bitstream| 0| 2097152|  100|0.55567887| PASSED 
# The file file_input_raw was rewound 17 times 
     diehard_opso| 0| 2097152|  100|0.20799917| PASSED 

相當於122,880,000/4 = 30,720,000 - 所以約31M的整數。