gpt4 book ai didi

testing - 在顽固的测试套件中使用包含随机数的 .txt 文件

转载 作者:行者123 更新时间:2023-11-28 19:43:47 25 4
gpt4 key购买 nike

我有几个 .txt 文件,其中包含由各种 RNG 生成的大量整数(大约 250 万)。我想使用顽固的测试套件来测试这些 RNG。

.txt 文件如下所示:

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

后面当然是更多的整数。我使用以下命令通过此 .txt 文件运行死忠

dieharder -f randdata.txt -a - g 202

我的问题是,我的 .txt 文件是否正确(特别是前几行),为什么这些行是必需的?我问这个的原因是因为一些 RNG 生成的每个 .txt 文件(有些好,有些坏)几乎每次测试都失败了,我想知道这是否是因为我在将 .txt 文件传递​​给顽固派时犯了一些错误,或者如果我的 RNG 很糟糕。

最佳答案

是的,那个输入文件看起来是正确的。似乎许多 dieharder 测试都失败了,即使是 dieharder 自己的生成器生成的 10M 输入也是如此:

$ dieharder -o -f example.input -t 10000000 # Generate an input file$ head -n 10 example.input#==================================================================# generator mt19937  seed = 3423143424#==================================================================type: dcount: 10000000numbit: 322310531048 80892946924230561144237891648$ 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=3000030000+0 records in30000+0 records out122880000 bytes transferred in 10.873818 secs (11300538 bytes/sec)$ du -sh /tmp/random117M    /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 整数。

关于testing - 在顽固的测试套件中使用包含随机数的 .txt 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32954045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com