Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nice Coder

RNG Entropy?

This topic is 5211 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I build my first RNG program today One uses the get QueryPerformanceFrequency, QueryPerformanceCounter and Gettickcount to find the difference. the code is like this,
QueryPerformanceFrequency curFreq ''Get the timer frequency
QueryPerformanceCounter curStart ''Get the start time
ctime = curStart / curFreq
k = GetTickCount / 1000
cdiff = Abs(k - ctime)
cdiff = cdiff * 1000
For the non-VB coders, ABS returns absolute positive numbers, like abs(-100) would return 100. i then remove the decimal point in cdiff, do some anti-mod-overloadcode then mod it with 2, to get each bit. I tested it using this http://www.fourmilab.ch/random/ And found the entropy to be 7.975742 bits per byte. I''ll post the extra information (extra statistics) once i finish my empirical study (i''m getting it to generate ten million random numbers, so i can find weaknesses). is 7.9 entropy bits per byte good? is my method of getting entropy good? Should i instead use hashes (maybe SHA-1 32767 bytes to get a 160 bit hash, what would happen?)?

Share this post


Link to post
Share on other sites
Advertisement
Test are in, in 10 million bytes of random data results were:
(sory for the wait... please post! - from someone who is lonely)

Value Char Occurrences Fraction
0 10233 0.001023
1 16892 0.001689
2 10702 0.001070
3 29508 0.002951
4 24078 0.002408
5 20931 0.002093
6 59368 0.005937
7 92877 0.009288
8 21741 0.002174
9 23727 0.002373
10 24584 0.002458
11 25076 0.002508
12 185833 0.018583
13 46966 0.004697
14 388889 0.038889
15 103821 0.010382
16 16366 0.001637
17 19750 0.001975
18 26965 0.002696
19 22606 0.002261
20 25279 0.002528
21 13617 0.001362
22 24684 0.002468
23 16771 0.001677
24 176597 0.017660
25 38661 0.003866
26 35345 0.003534
27 37016 0.003702
28 244716 0.024472
29 32557 0.003256
30 71130 0.007113
31 29198 0.002920
32 13456 0.001346
33 ! 23042 0.002304
34 " 17115 0.001711
35 # 38103 0.003810
36 $ 63850 0.006385
37 % 37417 0.003742
38 & 46705 0.004670
39 '' 40656 0.004066
40 ( 12939 0.001294
41 ) 18273 0.001827
42 * 14142 0.001414
43 + 15496 0.001550
44 , 36100 0.003610
45 - 38339 0.003834
46 . 29510 0.002951
47 / 17238 0.001724
48 0 23142 0.002314
49 1 45519 0.004552
50 2 44909 0.004491
51 3 32608 0.003261
52 4 23494 0.002349
53 5 16761 0.001676
54 6 44606 0.004461
55 7 14384 0.001438
56 8 89600 0.008960
57 9 44736 0.004474
58 : 21112 0.002111
59 ; 19154 0.001915
60 < 39783 0.003978
61 = 16603 0.001660
62 > 19304 0.001930
63 ? 11238 0.001124
64 @ 13297 0.001330
65 A 22137 0.002214
66 B 18585 0.001858
67 C 46730 0.004673
68 D 24341 0.002434
69 E 27736 0.002774
70 F 76627 0.007663
71 G 190154 0.019015
72 H 16054 0.001605
73 I 44728 0.004473
74 J 20017 0.002002
75 K 25301 0.002530
76 L 36920 0.003692
77 M 49093 0.004909
78 N 67955 0.006795
79 O 34471 0.003447
80 P 13726 0.001373
81 Q 20252 0.002025
82 R 39612 0.003961
83 S 30351 0.003035
84 T 17319 0.001732
85 U 14818 0.001482
86 V 21635 0.002163
87 W 14857 0.001486
88 X 34140 0.003414
89 Y 44280 0.004428
90 Z 37478 0.003748
91 [ 62958 0.006296
92 \ 38006 0.003801
93 ] 18200 0.001820
94 ^ 25002 0.002500
95 _ 14582 0.001458
96 ` 19723 0.001972
97 a 46117 0.004612
98 b 23121 0.002312
99 c 148784 0.014878
100 d 32994 0.003299
101 e 33514 0.003351
102 f 37213 0.003721
103 g 174350 0.017435
104 h 11209 0.001121
105 i 18678 0.001868
106 j 11386 0.001139
107 k 19269 0.001927
108 l 20716 0.002072
109 m 28350 0.002835
110 n 18452 0.001845
111 o 17038 0.001704
112 p 34067 0.003407
113 q 119777 0.011978
114 r 31021 0.003102
115 s 77583 0.007758
116 t 15167 0.001517
117 u 15580 0.001558
118 v 19865 0.001986
119 w 13754 0.001375
120 x 39359 0.003936
121 y 26775 0.002677
122 z 14995 0.001499
123 { 15950 0.001595
124 | 16982 0.001698
125 } 8632 0.000863
126 ~ 11583 0.001158
127 7302 0.000730
128 7131 0.000713
129 11021 0.001102
130 8522 0.000852
131 16115 0.001611
132 15414 0.001541
133 15011 0.001501
134 25710 0.002571
135 37815 0.003781
136 13669 0.001367
137 19845 0.001984
138 15335 0.001533
139 14928 0.001493
140 74998 0.007500
141 30327 0.003033
142 114151 0.011415
143 33819 0.003382
144 16379 0.001638
145 17225 0.001722
146 27798 0.002780
147 19948 0.001995
148 18444 0.001844
149 10951 0.001095
150 18039 0.001804
151 10886 0.001089
152 163099 0.016310
153 36219 0.003622
154 32724 0.003272
155 33135 0.003313
156 140759 0.014076
157 22592 0.002259
158 44243 0.004424
159 19494 0.001949
160 13997 0.001400
161 ¡ 23955 0.002395
162 ¢ 17681 0.001768
163 £ 35102 0.003510
164 ¤ 61443 0.006144
165 ¥ 36867 0.003687
166 ¦ 43800 0.004380
167 § 32853 0.003285
168 ¨ 14299 0.001430
169 © 20636 0.002064
170 ª 14281 0.001428
171 « 16908 0.001691
172 ¬ 29209 0.002921
173 ­ 38359 0.003836
174 ® 20092 0.002009
175 ¯ 13301 0.001330
176 ° 32026 0.003203
177 ± 61485 0.006148
178 ² 47841 0.004784
179 ³ 35060 0.003506
180 ´ 24258 0.002426
181 µ 19095 0.001909
182 ¶ 43718 0.004372
183 · 15400 0.001540
184 ¸ 176337 0.017634
185 ¹ 70004 0.007000
186 º 26663 0.002666
187 » 23652 0.002365
188 ¼ 44300 0.004430
189 ½ 17938 0.001794
190 ¾ 22036 0.002204
191 ¿ 13141 0.001314
192 À 10151 0.001015
193 Á 17616 0.001762
194 Â 15737 0.001574
195 Ã 36992 0.003699
196 Ä 18348 0.001835
197 Å 20322 0.002032
198 Æ 42980 0.004298
199 Ç 85317 0.008532
200 È 13819 0.001382
201 É 44474 0.004447
202 Ê 16906 0.001691
203 Ë 23599 0.002360
204 Ì 31517 0.003152
205 Í 44697 0.004470
206 Î 44483 0.004448
207 Ï 22882 0.002288
208 Ð 16623 0.001662
209 Ñ 27418 0.002742
210 Ò 37486 0.003749
211 Ó 34316 0.003432
212 Ô 15007 0.001501
213 Õ 13823 0.001382
214 Ö 17322 0.001732
215 × 12169 0.001217
216 Ø 37733 0.003773
217 Ù 45880 0.004588
218 Ú 36440 0.003644
219 Û 62426 0.006243
220 Ü 35770 0.003577
221 Ý 17298 0.001730
222 Þ 22497 0.002250
223 ß 13382 0.001338
224 à 24834 0.002483
225 á 62393 0.006239
226 â 28787 0.002879
227 ã 209053 0.020905
228 ä 35214 0.003521
229 å 33815 0.003381
230 æ 36338 0.003634
231 ç 159866 0.015987
232 è 15028 0.001503
233 é 23214 0.002321
234 ê 12889 0.001289
235 ë 22810 0.002281
236 ì 21356 0.002136
237 í 26337 0.002634
238 î 18743 0.001874
239 ï 15717 0.001572
240 ð 91585 0.009158
241 ñ 333050 0.033305
242 ò 42908 0.004291
243 ó 153282 0.015328
244 ô 23091 0.002309
245 õ 22313 0.002231
246 ö 22854 0.002285
247 ÷ 19778 0.001978
248 ø 82922 0.008292
249 ù 53568 0.005357
250 ú 20199 0.002020
251 û 22048 0.002205
252 ü 27080 0.002708
253 ý 10262 0.001026
254 þ 15711 0.001571
255 ÿ 9569 0.000957

Total: 10000013 1.000000

Entropy = 7.414464 bits per byte.

Optimum compression would reduce the size
of this 10000013 byte file by 7 percent.

Chi square distribution for 10000013 samples is 14211210.01, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bytes is 124.4440 (127.5 = random).
Monte Carlo value for Pi is 3.141098287 (error 0.02 percent).
Serial correlation coefficient is -0.072072 (totally uncorrelated = 0.0).
Value Char Occurrences Fraction
0 10233 0.001023
1 16892 0.001689
2 10702 0.001070
3 29508 0.002951
4 24078 0.002408
5 20931 0.002093
6 59368 0.005937
7 92877 0.009288
8 21741 0.002174
9 23727 0.002373
10 24584 0.002458
11 25076 0.002508
12 185833 0.018583
13 46966 0.004697
14 388889 0.038889
15 103821 0.010382
16 16366 0.001637
17 19750 0.001975
18 26965 0.002696
19 22606 0.002261
20 25279 0.002528
21 13617 0.001362
22 24684 0.002468
23 16771 0.001677
24 176597 0.017660
25 38661 0.003866
26 35345 0.003534
27 37016 0.003702
28 244716 0.024472
29 32557 0.003256
30 71130 0.007113
31 29198 0.002920
32 13456 0.001346
33 ! 23042 0.002304
34 "
17115 0.001711
35 # 38103 0.003810
36 $ 63850 0.006385
37 % 37417 0.003742
38 & 46705 0.004670
39 '' 40656 0.004066
40 ( 12939 0.001294
41 ) 18273 0.001827
42 * 14142 0.001414
43 + 15496 0.001550
44 , 36100 0.003610
45 - 38339 0.003834
46 . 29510 0.002951
47 / 17238 0.001724
48 0 23142 0.002314
49 1 45519 0.004552
50 2 44909 0.004491
51 3 32608 0.003261
52 4 23494 0.002349
53 5 16761 0.001676
54 6 44606 0.004461
55 7 14384 0.001438
56 8 89600 0.008960
57 9 44736 0.004474
58 : 21112 0.002111
59 ; 19154 0.001915
60 < 39783 0.003978
61 = 16603 0.001660
62 > 19304 0.001930
63 ? 11238 0.001124
64 @ 13297 0.001330
91 [ 62958 0.006296
92 \ 38006 0.003801
93
] 18200 0.001820
94 ^ 25002 0.002500
95 _ 14582 0.001458
96 ` 19723 0.001972
97 a 68254 0.006825
98 b 41706 0.004171
99 c 195514 0.019551
100 d 57335 0.005733
101 e 61250 0.006125
102 f 113840 0.011384
103 g 364504 0.036450
104 h 27263 0.002726
105 i 63406 0.006341
106 j 31403 0.003140
107 k 44570 0.004457
108 l 57636 0.005764
109 m 77443 0.007744
110 n 86407 0.008641
111 o 51509 0.005151
112 p 47793 0.004779
113 q 140029 0.014003
114 r 70633 0.007063
115 s 107934 0.010793
116 t 32486 0.003249
117 u 30398 0.003040
118 v 41500 0.004150
119 w 28611 0.002861
120 x 73499 0.007350
121 y 71055 0.007105
122 z 52473 0.005247
123 { 15950 0.001595
124 | 16982 0.001698
125 } 8632 0.000863
126 ~ 11583 0.001158
127 7302 0.000730
128 7131 0.000713
129 11021 0.001102
130 8522 0.000852
131 16115 0.001611
132 15414 0.001541
133 15011 0.001501
134 25710 0.002571
135 37815 0.003781
136 13669 0.001367
137 19845 0.001984
138 15335 0.001533
139 14928 0.001493
140 74998 0.007500
141 30327 0.003033
142 114151 0.011415
143 33819 0.003382
144 16379 0.001638
145 17225 0.001722
146 27798 0.002780
147 19948 0.001995
148 18444 0.001844
149 10951 0.001095
150 18039 0.001804
151 10886 0.001089
152 163099 0.016310
153 36219 0.003622
154 32724 0.003272
155 33135 0.003313
156 140759 0.014076
157 22592 0.002259
158 44243 0.004424
159 19494 0.001949
160 13997 0.001400
161 ¡ 23955 0.002395
162 ¢ 17681 0.001768
163 £ 35102 0.003510
164 ¤ 61443 0.006144
165 ¥ 36867 0.003687
166 ¦ 43800 0.004380
167 § 32853 0.003285
168 ¨ 14299 0.001430
169 © 20636 0.002064
170 ª 14281 0.001428
171 « 16908 0.001691
172 ¬ 29209 0.002921
173 ­ 38359 0.003836
174 ® 20092 0.002009
175 ¯ 13301 0.001330
176 ° 32026 0.003203
177 ± 61485 0.006148
178 ² 47841 0.004784
179 ³ 35060 0.003506
180 ´ 24258 0.002426
181 µ 19095 0.001909
182 ¶ 43718 0.004372
183 · 15400 0.001540
184 ¸ 176337 0.017634
185 ¹ 70004 0.007000
186 º 26663 0.002666
187 » 23652 0.002365
188 ¼ 44300 0.004430
189 ½ 17938 0.001794
190 ¾ 22036 0.002204
191 ¿ 13141 0.001314
215 × 12169 0.001217
223 ß 13382 0.001338
224 à 34985 0.003498
225 á 80009 0.008001
226 â 44524 0.004452
227 ã 246045 0.024604
228 ä 53562 0.005356
229 å 54137 0.005414
230 æ 79318 0.007932
231 ç 245183 0.024518
232 è 28847 0.002885
233 é 67688 0.006769
234 ê 29795 0.002979
235 ë 46409 0.004641
236 ì 52873 0.005287
237 í 71034 0.007103
238 î 63226 0.006323
239 ï 38599 0.003860
240 ð 108208 0.010821
241 ñ 360468 0.036047
242 ò 80394 0.008039
243 ó 187598 0.018760
244 ô 38098 0.003810
245 õ 36136 0.003614
246 ö 40176 0.004018
247 ÷ 19778 0.001978
248 ø 120655 0.012065
249 ù 99448 0.009945
250 ú 56639 0.005664
251 û 84474 0.008447
252 ü 62850 0.006285
253 ý 27560 0.002756
254 þ 38208 0.003821
255 ÿ 9569 0.000957

Total: 10000013 1.000000

Entropy = 7.024495 bits per byte.

Optimum compression would reduce the size
of this 10000013 byte file by 12 percent.

Chi square distribution for 10000013 samples is 20429391.96, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bytes is 130.5214 (127.5 = random).
Monte Carlo value for Pi is 2.902380078 (error 7.61 percent).
Serial correlation coefficient is -0.058784 (totally uncorrelated = 0.0).
Entropy = 0.999967 bits per bit.

Optimum compression would reduce the size
of this 80000104 bit file by 0 percent.

Chi square distribution for 80000104 samples is 3648.91, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bits is 0.4966 (0.5 = random).
Monte Carlo value for Pi is 3.141098287 (error 0.02 percent).
Serial correlation coefficient is 0.102919 (totally uncorrelated = 0.0).
Value Char Occurrences Fraction
0 40270197 0.503377
1 39729907 0.496623

Total: 80000104 1.000000

Entropy = 0.999967 bits per bit.

Optimum compression would reduce the size
of this 80000104 bit file by 0 percent.

Chi square distribution for 80000104 samples is 3648.91, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bits is 0.4966 (0.5 = random).
Monte Carlo value for Pi is 3.141098287 (error 0.02 percent).
Serial correlation coefficient is 0.102919 (totally uncorrelated = 0.0).
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,10000013,7.414464,14211210.008021,124.443998,3.141098,-0.072072
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,10000013,7.414464,14211210.008021,124.443998,3.141098,-0.072072
2,Value,Occurrences,Fraction
3,0,10233,0.001023
3,1,16892,0.001689
3,2,10702,0.001070
3,3,29508,0.002951
3,4,24078,0.002408
3,5,20931,0.002093
3,6,59368,0.005937
3,7,92877,0.009288
3,8,21741,0.002174
3,9,23727,0.002373
3,10,24584,0.002458
3,11,25076,0.002508
3,12,185833,0.018583
3,13,46966,0.004697
3,14,388889,0.038889
3,15,103821,0.010382
3,16,16366,0.001637
3,17,19750,0.001975
3,18,26965,0.002696
3,19,22606,0.002261
3,20,25279,0.002528
3,21,13617,0.001362
3,22,24684,0.002468
3,23,16771,0.001677
3,24,176597,0.017660
3,25,38661,0.003866
3,26,35345,0.003534
3,27,37016,0.003702
3,28,244716,0.024472
3,29,32557,0.003256
3,30,71130,0.007113
3,31,29198,0.002920
3,32,13456,0.001346
3,33,23042,0.002304
3,34,17115,0.001711
3,35,38103,0.003810
3,36,63850,0.006385
3,37,37417,0.003742
3,38,46705,0.004670
3,39,40656,0.004066
3,40,12939,0.001294
3,41,18273,0.001827
3,42,14142,0.001414
3,43,15496,0.001550
3,44,36100,0.003610
3,45,38339,0.003834
3,46,29510,0.002951
3,47,17238,0.001724
3,48,23142,0.002314
3,49,45519,0.004552
3,50,44909,0.004491
3,51,32608,0.003261
3,52,23494,0.002349
3,53,16761,0.001676
3,54,44606,0.004461
3,55,14384,0.001438
3,56,89600,0.008960
3,57,44736,0.004474
3,58,21112,0.002111
3,59,19154,0.001915
3,60,39783,0.003978
3,61,16603,0.001660
3,62,19304,0.001930
3,63,11238,0.001124
3,64,13297,0.001330
3,65,22137,0.002214
3,66,18585,0.001858
3,67,46730,0.004673
3,68,24341,0.002434
3,69,27736,0.002774
3,70,76627,0.007663
3,71,190154,0.019015
3,72,16054,0.001605
3,73,44728,0.004473
3,74,20017,0.002002
3,75,25301,0.002530
3,76,36920,0.003692
3,77,49093,0.004909
3,78,67955,0.006795
3,79,34471,0.003447
3,80,13726,0.001373
3,81,20252,0.002025
3,82,39612,0.003961
3,83,30351,0.003035
3,84,17319,0.001732
3,85,14818,0.001482
3,86,21635,0.002163
3,87,14857,0.001486
3,88,34140,0.003414
3,89,44280,0.004428
3,90,37478,0.003748
3,91,62958,0.006296
3,92,38006,0.003801
3,93,18200,0.001820
3,94,25002,0.002500
3,95,14582,0.001458
3,96,19723,0.001972
3,97,46117,0.004612
3,98,23121,0.002312
3,99,148784,0.014878
3,100,32994,0.003299
3,101,33514,0.003351
3,102,37213,0.003721
3,103,174350,0.017435
3,104,11209,0.001121
3,105,18678,0.001868
3,106,11386,0.001139
3,107,19269,0.001927
3,108,20716,0.002072
3,109,28350,0.002835
3,110,18452,0.001845
3,111,17038,0.001704
3,112,34067,0.003407
3,113,119777,0.011978
3,114,31021,0.003102
3,115,77583,0.007758
3,116,15167,0.001517
3,117,15580,0.001558
3,118,19865,0.001986
3,119,13754,0.001375
3,120,39359,0.003936
3,121,26775,0.002677
3,122,14995,0.001499
3,123,15950,0.001595
3,124,16982,0.001698
3,125,8632,0.000863
3,126,11583,0.001158
3,127,7302,0.000730
3,128,7131,0.000713
3,129,11021,0.001102
3,130,8522,0.000852
3,131,16115,0.001611
3,132,15414,0.001541
3,133,15011,0.001501
3,134,25710,0.002571
3,135,37815,0.003781
3,136,13669,0.001367
3,137,19845,0.001984
3,138,15335,0.001533
3,139,14928,0.001493
3,140,74998,0.007500
3,141,30327,0.003033
3,142,114151,0.011415
3,143,33819,0.003382
3,144,16379,0.001638
3,145,17225,0.001722
3,146,27798,0.002780
3,147,19948,0.001995
3,148,18444,0.001844
3,149,10951,0.001095
3,150,18039,0.001804
3,151,10886,0.001089
3,152,163099,0.016310
3,153,36219,0.003622
3,154,32724,0.003272
3,155,33135,0.003313
3,156,140759,0.014076
3,157,22592,0.002259
3,158,44243,0.004424
3,159,19494,0.001949
3,160,13997,0.001400
3,161,23955,0.002395
3,162,17681,0.001768
3,163,35102,0.003510
3,164,61443,0.006144
3,165,36867,0.003687
3,166,43800,0.004380
3,167,32853,0.003285
3,168,14299,0.001430
3,169,20636,0.002064
3,170,14281,0.001428
3,171,16908,0.001691
3,172,29209,0.002921
3,173,38359,0.003836
3,174,20092,0.002009
3,175,13301,0.001330
3,176,32026,0.003203
3,177,61485,0.006148
3,178,47841,0.004784
3,179,35060,0.003506
3,180,24258,0.002426
3,181,19095,0.001909
3,182,43718,0.004372
3,183,15400,0.001540
3,184,176337,0.017634
3,185,70004,0.007000
3,186,26663,0.002666
3,187,23652,0.002365
3,188,44300,0.004430
3,189,17938,0.001794
3,190,22036,0.002204
3,191,13141,0.001314
3,192,10151,0.001015
3,193,17616,0.001762
3,194,15737,0.001574
3,195,36992,0.003699
3,196,18348,0.001835
3,197,20322,0.002032
3,198,42980,0.004298
3,199,85317,0.008532
3,200,13819,0.001382
3,201,44474,0.004447
3,202,16906,0.001691
3,203,23599,0.002360
3,204,31517,0.003152
3,205,44697,0.004470
3,206,44483,0.004448
3,207,22882,0.002288
3,208,16623,0.001662
3,209,27418,0.002742
3,210,37486,0.003749
3,211,34316,0.003432
3,212,15007,0.001501
3,213,13823,0.001382
3,214,17322,0.001732
3,215,12169,0.001217
3,216,37733,0.003773
3,217,45880,0.004588
3,218,36440,0.003644
3,219,62426,0.006243
3,220,35770,0.003577
3,221,17298,0.001730
3,222,22497,0.002250
3,223,13382,0.001338
3,224,24834,0.002483
3,225,62393,0.006239
3,226,28787,0.002879
3,227,209053,0.020905
3,228,35214,0.003521
3,229,33815,0.003381
3,230,36338,0.003634
3,231,159866,0.015987
3,232,15028,0.001503
3,233,23214,0.002321
3,234,12889,0.001289
3,235,22810,0.002281
3,236,21356,0.002136
3,237,26337,0.002634
3,238,18743,0.001874
3,239,15717,0.001572
3,240,91585,0.009158
3,241,333050,0.033305
3,242,42908,0.004291
3,243,153282,0.015328
3,244,23091,0.002309
3,245,22313,0.002231
3,246,22854,0.002285
3,247,19778,0.001978
3,248,82922,0.008292
3,249,53568,0.005357
3,250,20199,0.002020
3,251,22048,0.002205
3,252,27080,0.002708
3,253,10262,0.001026
3,254,15711,0.001571
3,255,9569,0.000957
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,10000013,7.024495,20429391.964039,130.521417,2.902380,-0.058784
0,File-bits,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,80000104,0.999967,3648.911308,0.496623,3.141098,0.102919
0,File-bits,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,80000104,0.999967,3648.911308,0.496623,3.141098,0.102919
2,Value,Occurrences,Fraction
3,0,40270197,0.503377
3,1,39729907,0.496623

Share this post


Link to post
Share on other sites
You left out a lot of code.

I don't understand why you use GetTickCount. It seems to me that if you modify your method by removing the GetTickCount part and just use the raw value from QueryPerformanceCounter, you would get the same (or better) results.

Some observations (though I'm not sure of the statistical significance):

The distribution does not seem very uniform. The average per character should around 39,000 but most are much smaller except a few that are much much larger.

Also, notice that the means are 130.5214 and 124.4440. With 10,000,000 samples, I would expect the means to be very very close to 127.5. This is probably related to the lumpy distribution.



John Bolton
Page 44 Studios
Current project: NHL Faceoff 2005 PS2


[edited by - JohnBolton on May 8, 2004 2:50:03 PM]

Share this post


Link to post
Share on other sites
I used Gettickcount because it sometimes Lags ahead/behind Queryperformancecounter. (from my tests, not much, but its enough.)

The way i got my bits is by taking

do until cdiff < 32767 'make sure mod doesn't overload
cdiff = cdiff / 255
doevents
loop

rbit = cdiff mod 2

I then stack the rbits to build 8-bit bytes
Then use a binary-decimal converter to convert them into bytes
then i pack them into the file.


Is this a good way to produce the bits?
This is my first (psudo-ish) Random number Generator! (is it an OK first attempt?)
And Can i improve entropy/randomness by putting a few KB of my random number generator into a Hash algarithm? (I just happen to have an MD5 DLL hanging around).

Should i add a wait inbetween collection of bits?
so instead of

do
Queryperformantscounter curstart
Gettickcount
get bit
add bit to byte
loop

It would be

do
wait n ms
Queryperformantscounter
Gettickcount
Get bit
add bit to byte
loop

?
Thank you for posting (this is my third thread, about my 100dreth post).
*edit-still getting used to the source tags*
DE NC

[edited by - Nice coder on May 8, 2004 9:24:42 PM]

Share this post


Link to post
Share on other sites
I really think that using GetTickCount is reducing the randomness. Here''s why.

On my system, GetTickCount updates 60 times per second and the frequency of QueryPerformanceCounter is 3.58 MHz. The timing of these two counters is extremely precise (and probably based on the same timer), so hoping to gain randomness due to timing fluctuation is not realistic. Assuming that GTC and QPC are synchronized every 1/60th of a second, your random value is simply the number of QPC ticks in the last 1/60th of a second. The range of that value is 0 to 59500 (3,570,000/60) and that is only 16 bits.

If you use QPC by itself, the counter will count (at 3.58 MHz) through the bottom 24 bits every 5 seconds and the bottom 32 bits every 20 minutes.

Why even bother with GetTickCount?

Share this post


Link to post
Share on other sites
Thank you for the info (im going to fix that soon).

Would i use
Queryperformantscounter curstart
Then convert it to binary.
Then use the number of 1''s % 2 to find the random bit?
Would this be more randomish?
Should i hash this data?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!