如果你可以搞到一个真随机数发生器的设备,你可以通过USB接口将真随机数传输到PC。如图可以看到传输的速度大约有40M比特/秒。我的这款真随机数发生器只有一块真随机数发生器芯片,如果多放几颗,速度可以达到300M比特/秒以上。接受了10M比特的真随机数,因为真随机数发生器都是2进制的只会产生0或1,所以可以用0-1比来衡量真随机数的熵值,0-1比越接近50%,熵值(香浓熵)越高,越接近1(对于2进制数据,满熵是1)。如图可以看到真随机数发生器产生的数据熵值在0.999999以上。
如何来评估随机数的好坏呢?我们可以将采集到的随机数画成bit位图,黑色代表0,白色代表1,如下图所示。右下角是网站水印的原因有点不正常。
你还可以使用ACF测试来查看随机数前后之间的相关性。
ACF测试指的是自相关函数(Autocorrelation Function)测试。自相关函数是一种用于衡量时间序列数据中各个时刻观测值之间相关性的统计方法。在时间序列分析中,了解观测值之间的相关性是非常重要的,因为它可以帮助我们理解数据的结构和预测未来的值。
ACF测试通过计算时间序列数据在不同时间滞后下的相关系数来评估数据的自相关性。具体来说,对于给定的时间序列数据,ACF测试会计算数据在不同时间滞后下的相关系数,并绘制出自相关函数图表。通过观察这些自相关函数图表,我们可以判断时间序列数据是否存在任何自相关性,并了解相关性的强度和模式。
可以看到真随机数的自相关性是非常小的,自相关性都在0.001以下。
还可以使用美国国家标准研究院的随机数发生器评估标准来测试随机数的质量,NIST800-22,用测试代码跑出来可以看到结果如下,全部通过(每一项均未出现*就代表通过了):
------------------------------------------------------------------------------
RESULTS FOR THE UNIFORMITY OF P-VALUES AND THE PROPORTION OF PASSING SEQUENCES
------------------------------------------------------------------------------
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 P-VALUE PROPORTION STATISTICAL TEST
------------------------------------------------------------------------------
97 107 104 107 97 95 98 93 104 98 0.985788 995/1000 Frequency
107 90 84 100 100 105 99 88 105 122 0.286836 990/1000 BlockFrequency
90 114 94 89 105 106 94 108 106 94 0.651693 993/1000 CumulativeSums
99 101 109 100 106 86 112 92 101 94 0.779188 994/1000 CumulativeSums
113 94 126 95 96 88 93 96 92 107 0.189625 985/1000 Runs
88 108 107 87 98 101 107 97 105 102 0.818343 990/1000 LongestRun
104 97 95 102 101 97 101 123 86 94 0.508172 993/1000 Rank
104 125 99 106 97 86 97 100 102 84 0.241741 993/1000 FFT
86 102 100 92 85 105 108 86 112 124 0.092597 986/1000 NonOverlappingTemplate
85 107 101 95 122 91 102 91 102 104 0.375313 992/1000 NonOverlappingTemplate
88 89 99 108 99 104 107 108 93 105 0.803720 989/1000 NonOverlappingTemplate
112 108 102 113 93 97 97 103 90 85 0.552383 994/1000 NonOverlappingTemplate
115 110 108 100 100 107 89 90 101 80 0.304126 990/1000 NonOverlappingTemplate
101 99 87 105 90 97 110 107 114 90 0.585209 994/1000 NonOverlappingTemplate
86 90 89 114 104 116 110 94 105 92 0.268917 995/1000 NonOverlappingTemplate
110 95 85 92 104 123 101 91 102 97 0.308561 985/1000 NonOverlappingTemplate
95 105 86 96 98 98 103 110 94 115 0.699313 989/1000 NonOverlappingTemplate
112 101 94 107 102 96 106 84 93 105 0.723804 991/1000 NonOverlappingTemplate
81 84 86 110 101 102 128 99 104 105 0.042255 992/1000 NonOverlappingTemplate
117 99 88 87 86 109 102 109 96 107 0.326749 994/1000 NonOverlappingTemplate
85 104 111 110 104 84 93 94 108 107 0.408275 992/1000 NonOverlappingTemplate
102 116 90 96 100 102 82 103 113 96 0.439122 991/1000 NonOverlappingTemplate
96 110 87 107 90 98 104 106 94 108 0.749884 993/1000 NonOverlappingTemplate
88 97 88 95 105 114 100 116 114 83 0.169981 992/1000 NonOverlappingTemplate
95 104 86 103 124 96 100 110 91 91 0.275709 991/1000 NonOverlappingTemplate
101 92 104 107 106 85 92 114 99 100 0.686955 990/1000 NonOverlappingTemplate
99 119 112 97 112 84 84 97 97 99 0.219006 989/1000 NonOverlappingTemplate
101 97 96 100 86 100 106 98 106 110 0.912724 994/1000 NonOverlappingTemplate
93 93 82 82 106 104 96 114 104 126 0.048404 993/1000 NonOverlappingTemplate
104 84 114 84 96 101 113 115 84 105 0.116746 989/1000 NonOverlappingTemplate
95 99 108 98 88 102 91 106 110 103 0.861264 991/1000 NonOverlappingTemplate
111 89 100 96 101 87 110 104 106 96 0.743915 988/1000 NonOverlappingTemplate
103 98 99 87 86 97 92 112 118 108 0.363593 989/1000 NonOverlappingTemplate
104 95 87 104 104 105 104 98 109 90 0.861264 991/1000 NonOverlappingTemplate
90 103 101 101 111 101 95 108 101 89 0.880145 991/1000 NonOverlappingTemplate
90 101 100 97 88 124 103 96 111 90 0.292519 994/1000 NonOverlappingTemplate
107 111 93 87 102 102 105 111 91 91 0.632955 994/1000 NonOverlappingTemplate
104 94 110 96 103 90 106 109 106 82 0.581082 997/1000 NonOverlappingTemplate
106 103 93 102 95 118 90 108 101 84 0.467322 995/1000 NonOverlappingTemplate
100 122 89 102 94 91 100 100 110 92 0.446556 985/1000 NonOverlappingTemplate
108 88 109 101 110 86 95 104 98 101 0.707513 985/1000 NonOverlappingTemplate
117 107 111 80 113 102 78 96 103 93 0.068999 986/1000 NonOverlappingTemplate
110 90 104 105 85 115 114 85 90 102 0.204439 993/1000 NonOverlappingTemplate
104 96 89 107 100 112 93 100 98 101 0.911413 991/1000 NonOverlappingTemplate
106 96 104 86 114 102 91 104 109 88 0.548314 990/1000 NonOverlappingTemplate
97 93 113 86 123 87 104 90 94 113 0.108150 990/1000 NonOverlappingTemplate
100 101 100 102 93 78 117 109 93 107 0.345650 991/1000 NonOverlappingTemplate
96 91 114 88 83 101 88 111 115 113 0.127393 993/1000 NonOverlappingTemplate
102 91 100 96 88 115 107 96 92 113 0.566688 990/1000 NonOverlappingTemplate
76 105 105 90 119 98 107 97 96 107 0.205531 992/1000 NonOverlappingTemplate
112 102 102 101 99 86 94 88 130 86 0.061647 988/1000 NonOverlappingTemplate
100 98 107 113 99 101 90 105 85 102 0.761719 992/1000 NonOverlappingTemplate
104 90 93 99 95 114 103 100 90 112 0.699313 990/1000 NonOverlappingTemplate
100 91 82 94 104 111 109 106 94 109 0.522100 988/1000 NonOverlappingTemplate
95 105 105 105 94 95 97 96 107 101 0.984415 992/1000 NonOverlappingTemplate
105 107 124 97 104 83 102 83 99 96 0.174728 993/1000 NonOverlappingTemplate
96 106 94 105 82 110 110 103 101 93 0.641284 991/1000 NonOverlappingTemplate
88 114 105 102 80 123 90 97 114 87 0.038565 992/1000 NonOverlappingTemplate
104 106 103 99 78 111 89 86 108 116 0.160805 991/1000 NonOverlappingTemplate
115 95 100 102 88 104 93 88 100 115 0.502247 984/1000 NonOverlappingTemplate
107 114 87 106 93 108 98 105 90 92 0.579021 988/1000 NonOverlappingTemplate
97 99 102 107 102 98 112 99 97 87 0.915317 993/1000 NonOverlappingTemplate
99 97 98 89 94 105 99 97 121 101 0.691081 989/1000 NonOverlappingTemplate
94 105 107 101 104 88 93 101 95 112 0.842937 992/1000 NonOverlappingTemplate
101 123 106 107 100 90 90 99 102 82 0.246750 987/1000 NonOverlappingTemplate
97 101 106 94 108 99 92 98 102 103 0.986227 992/1000 NonOverlappingTemplate
99 87 113 94 106 110 104 84 103 100 0.542228 990/1000 NonOverlappingTemplate
95 87 107 102 102 102 106 78 107 114 0.334538 987/1000 NonOverlappingTemplate
91 101 102 110 106 124 110 76 89 91 0.052610 992/1000 NonOverlappingTemplate
91 85 100 109 106 100 101 82 124 102 0.150340 993/1000 NonOverlappingTemplate
102 101 103 84 97 98 100 92 126 97 0.325206 989/1000 NonOverlappingTemplate
95 105 105 107 83 94 111 110 92 98 0.597620 988/1000 NonOverlappingTemplate
112 103 95 90 93 103 111 102 104 87 0.693142 991/1000 NonOverlappingTemplate
103 109 112 91 95 96 102 96 91 105 0.849708 991/1000 NonOverlappingTemplate
97 108 108 94 94 100 95 111 87 106 0.779188 989/1000 NonOverlappingTemplate
94 110 92 98 99 99 110 104 88 106 0.832561 989/1000 NonOverlappingTemplate
105 84 95 103 89 103 105 105 108 103 0.771469 991/1000 NonOverlappingTemplate
100 104 103 106 109 94 102 111 100 71 0.246750 991/1000 NonOverlappingTemplate
114 104 105 109 90 87 115 99 85 92 0.274341 988/1000 NonOverlappingTemplate
95 93 91 100 106 110 103 96 119 87 0.488534 991/1000 NonOverlappingTemplate
111 109 89 96 90 102 93 114 96 100 0.632955 987/1000 NonOverlappingTemplate
94 107 111 98 104 90 104 102 86 104 0.781106 992/1000 NonOverlappingTemplate
86 101 101 90 88 104 108 86 111 125 0.101311 986/1000 NonOverlappingTemplate
111 114 93 108 94 106 105 95 86 88 0.444691 988/1000 NonOverlappingTemplate
111 99 85 88 101 99 99 99 110 109 0.662091 987/1000 NonOverlappingTemplate
104 93 102 84 98 80 107 118 112 102 0.186566 987/1000 NonOverlappingTemplate
108 94 118 81 99 82 99 96 112 111 0.125200 993/1000 NonOverlappingTemplate
99 102 110 102 88 98 108 93 108 92 0.836048 989/1000 NonOverlappingTemplate
100 77 97 104 102 103 117 107 93 100 0.388990 991/1000 NonOverlappingTemplate
93 114 117 89 117 92 89 81 104 104 0.085068 990/1000 NonOverlappingTemplate
91 87 115 115 108 100 93 87 101 103 0.357000 991/1000 NonOverlappingTemplate
102 104 97 121 95 92 106 91 94 98 0.620465 988/1000 NonOverlappingTemplate
91 84 92 108 93 112 102 99 111 108 0.486588 990/1000 NonOverlappingTemplate
101 94 109 101 92 97 94 102 113 97 0.904708 985/1000 NonOverlappingTemplate
90 124 96 96 96 87 83 103 112 113 0.089843 991/1000 NonOverlappingTemplate
103 108 101 89 98 103 89 112 95 102 0.832561 983/1000 NonOverlappingTemplate
88 103 111 111 98 80 110 102 89 108 0.284024 993/1000 NonOverlappingTemplate
96 109 98 117 79 107 105 98 114 77 0.060112 989/1000 NonOverlappingTemplate
120 102 93 99 96 106 88 96 97 103 0.653773 987/1000 NonOverlappingTemplate
109 90 105 115 101 97 89 100 101 93 0.727851 987/1000 NonOverlappingTemplate
106 92 107 108 91 102 96 106 101 91 0.889118 988/1000 NonOverlappingTemplate
96 103 99 104 95 111 97 97 99 99 0.990138 984/1000 NonOverlappingTemplate
87 98 93 94 111 90 117 118 100 92 0.239266 990/1000 NonOverlappingTemplate
94 80 104 92 117 111 84 112 115 91 0.060492 991/1000 NonOverlappingTemplate
92 95 92 106 96 93 102 105 113 106 0.844641 987/1000 NonOverlappingTemplate
85 88 102 125 96 92 110 100 105 97 0.206629 993/1000 NonOverlappingTemplate
110 100 104 96 96 114 99 97 83 101 0.695200 988/1000 NonOverlappingTemplate
106 98 102 105 99 86 112 95 100 97 0.880145 990/1000 NonOverlappingTemplate
97 104 79 97 112 93 108 118 104 88 0.204439 988/1000 NonOverlappingTemplate
109 102 107 86 95 108 95 98 88 112 0.599693 988/1000 NonOverlappingTemplate
108 119 115 107 88 93 84 92 95 99 0.192724 983/1000 NonOverlappingTemplate
93 81 109 114 94 96 103 104 94 112 0.397688 988/1000 NonOverlappingTemplate
114 82 96 103 97 83 115 107 101 102 0.260930 986/1000 NonOverlappingTemplate
113 100 101 89 107 112 96 98 90 94 0.699313 987/1000 NonOverlappingTemplate
112 95 93 120 88 105 88 96 102 101 0.390721 990/1000 NonOverlappingTemplate
95 114 97 101 99 91 103 111 99 90 0.794391 983/1000 NonOverlappingTemplate
93 107 76 113 101 118 97 101 98 96 0.214439 992/1000 NonOverlappingTemplate
93 89 108 99 81 96 109 96 117 112 0.248014 990/1000 NonOverlappingTemplate
96 106 90 99 93 99 116 93 110 98 0.727851 993/1000 NonOverlappingTemplate
93 104 97 103 96 100 102 109 102 94 0.987079 991/1000 NonOverlappingTemplate
104 111 102 80 87 109 97 105 98 107 0.457825 992/1000 NonOverlappingTemplate
88 94 126 92 104 90 91 101 97 117 0.116746 996/1000 NonOverlappingTemplate
103 98 103 101 113 80 107 99 99 97 0.686955 990/1000 NonOverlappingTemplate
112 98 113 96 99 89 89 101 102 101 0.757790 987/1000 NonOverlappingTemplate
85 93 89 109 128 99 107 95 102 93 0.126658 990/1000 NonOverlappingTemplate
101 114 113 103 104 111 89 98 82 85 0.221317 987/1000 NonOverlappingTemplate
88 118 99 103 109 85 90 105 95 108 0.352107 987/1000 NonOverlappingTemplate
102 106 105 103 99 106 76 98 105 100 0.620465 991/1000 NonOverlappingTemplate
105 107 95 92 101 99 98 91 96 116 0.814724 987/1000 NonOverlappingTemplate
106 69 112 91 94 108 115 97 101 107 0.065639 994/1000 NonOverlappingTemplate
115 113 101 91 102 84 105 112 90 87 0.228367 997/1000 NonOverlappingTemplate
91 106 112 96 104 110 97 102 93 89 0.763677 991/1000 NonOverlappingTemplate
119 92 119 98 95 98 86 96 106 91 0.244236 992/1000 NonOverlappingTemplate
114 92 97 105 115 87 86 97 103 104 0.420827 993/1000 NonOverlappingTemplate
81 104 81 123 109 87 118 90 105 102 0.019857 994/1000 NonOverlappingTemplate
115 104 108 109 79 85 108 96 93 103 0.219006 987/1000 NonOverlappingTemplate
105 77 94 101 105 114 99 106 111 88 0.266235 990/1000 NonOverlappingTemplate
100 99 84 100 87 109 107 112 109 93 0.504219 988/1000 NonOverlappingTemplate
101 113 95 105 97 97 110 89 106 87 0.674543 997/1000 NonOverlappingTemplate
124 95 84 119 100 94 100 94 96 94 0.144504 983/1000 NonOverlappingTemplate
107 114 109 94 86 104 75 105 111 95 0.133404 985/1000 NonOverlappingTemplate
103 105 97 94 95 104 100 103 96 103 0.996839 985/1000 NonOverlappingTemplate
98 103 96 114 98 81 92 102 108 108 0.548314 994/1000 NonOverlappingTemplate
110 103 100 118 107 100 93 93 89 87 0.465415 989/1000 NonOverlappingTemplate
110 106 92 100 101 93 79 104 101 114 0.433590 993/1000 NonOverlappingTemplate
97 118 111 128 105 92 91 79 90 89 0.014051 987/1000 NonOverlappingTemplate
92 101 105 94 109 103 98 87 109 102 0.856359 992/1000 NonOverlappingTemplate
114 105 94 87 100 103 102 87 109 99 0.647530 994/1000 NonOverlappingTemplate
102 100 106 113 97 82 113 93 100 94 0.538182 990/1000 NonOverlappingTemplate
99 114 100 105 108 96 103 87 97 91 0.769527 995/1000 NonOverlappingTemplate
107 102 98 106 88 114 101 101 93 90 0.755819 988/1000 NonOverlappingTemplate
91 105 101 114 98 102 103 99 94 93 0.907419 992/1000 NonOverlappingTemplate
101 95 96 115 119 96 96 95 87 100 0.480771 991/1000 NonOverlappingTemplate
105 105 87 95 102 98 102 99 92 115 0.792508 991/1000 NonOverlappingTemplate
111 111 103 107 108 90 96 96 108 70 0.102526 990/1000 NonOverlappingTemplate
94 107 111 97 105 90 105 100 87 104 0.788728 992/1000 NonOverlappingTemplate
118 87 109 101 90 97 100 96 101 101 0.635037 986/1000 OverlappingTemplate
109 109 102 100 98 112 91 96 86 97 0.723804 984/1000 Universal
84 94 105 98 112 109 86 105 111 96 0.433590 996/1000 ApproximateEntropy
54 67 61 60 83 63 69 64 51 67 0.260784 637/639 RandomExcursions
56 55 62 75 59 72 55 70 71 64 0.488503 630/639 RandomExcursions
68 67 58 63 59 69 76 59 56 64 0.778883 630/639 RandomExcursions
56 59 70 80 69 59 49 62 62 73 0.216007 635/639 RandomExcursions
68 62 58 63 73 49 60 75 67 64 0.513493 634/639 RandomExcursions
79 65 66 59 66 54 75 47 60 68 0.169921 630/639 RandomExcursions
66 66 50 60 82 66 51 66 65 67 0.228953 630/639 RandomExcursions
59 72 54 55 62 69 71 73 57 67 0.548605 634/639 RandomExcursions
56 65 56 68 55 66 77 65 67 64 0.676714 634/639 RandomExcursionsVariant
51 67 72 60 60 71 54 67 74 63 0.476207 632/639 RandomExcursionsVariant
57 68 67 53 72 57 67 68 66 64 0.790981 633/639 RandomExcursionsVariant
65 63 59 49 73 66 66 65 64 69 0.744675 636/639 RandomExcursionsVariant
66 56 53 68 75 63 57 69 58 74 0.470113 633/639 RandomExcursionsVariant
60 61 68 55 73 63 69 57 66 67 0.855862 635/639 RandomExcursionsVariant
59 67 61 70 61 54 63 75 50 79 0.228953 637/639 RandomExcursionsVariant
57 66 57 72 67 60 73 53 60 74 0.513493 636/639 RandomExcursionsVariant
50 68 69 63 79 63 65 54 71 57 0.300407 634/639 RandomExcursionsVariant
77 52 65 65 60 80 63 70 50 57 0.125177 630/639 RandomExcursionsVariant
64 62 60 73 58 61 73 66 63 59 0.897314 633/639 RandomExcursionsVariant
61 61 57 63 60 72 67 71 56 71 0.817398 632/639 RandomExcursionsVariant
67 45 73 63 61 66 66 62 71 65 0.491599 631/639 RandomExcursionsVariant
62 57 70 52 59 70 59 69 69 72 0.637119 631/639 RandomExcursionsVariant
69 56 60 52 66 68 58 73 64 73 0.581115 634/639 RandomExcursionsVariant
63 61 66 56 64 62 85 63 57 62 0.411329 636/639 RandomExcursionsVariant
53 68 65 65 70 64 73 52 66 63 0.683283 636/639 RandomExcursionsVariant
55 53 71 60 68 68 63 68 73 60 0.670133 635/639 RandomExcursionsVariant
99 103 116 94 94 98 101 103 92 100 0.900569 990/1000 Serial
101 103 103 96 96 102 98 116 89 96 0.873987 989/1000 Serial
122 100 89 92 94 107 110 92 99 95 0.397688 992/1000 LinearComplexity
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The minimum pass rate for each statistical test with the exception of the
random excursion (variant) test is approximately = 980 for a
sample size = 1000 binary sequences.
The minimum pass rate for the random excursion (variant) test
is approximately = 625 for a sample size = 639 binary sequences.
For further guidelines construct a probability table using the MAPLE program
provided in the addendum section of the documentation.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
评论区
共 12 条评论热门最新