daily pastebin goal


a guest May 27th, 2012 27 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .\" Manpage for ent.
  2. .\" Man page created by Paolo Palmieri from the program homepage http://www.fourmilab.ch/random/.
  3. .TH man 1 "28 January 2008" "1.0" "ent man page"
  4. .SH NAME
  5. \fBent\fP \- pseudorandom number sequence test
  8. \fBent\fP [ \fB-b -c -f -t -u\fP ] [ \fIinfile\fP ]
  11. \fBent\fP performs a variety of tests on the stream of bytes in \fIinfile\fP (or standard input if no \fIinfile\fP is specified) and produces output as follows on the standard output stream:
  13.     Entropy = 7.980627 bits per character.
  15.     Optimum compression would reduce the size
  16.     of this 51768 character file by 0 percent.
  18.     Chi square distribution for 51768 samples is 1542.26, and randomly
  19.     would exceed this value less than 0.01 percent of the times.
  21.     Arithmetic mean value of data bytes is 125.93 (127.5 = random).
  22.     Monte Carlo value for Pi is 3.169834647 (error 0.90 percent).
  23.     Serial correlation coefficient is 0.004249 (totally uncorrelated = 0.0).
  25. The values calculated are as follows:
  27. .SS "Entropy"
  28. The information density of the contents of the file, expressed as a number of bits per character. The results above, which resulted from processing an image file compressed with JPEG, indicate that the file is extremely dense in information—essentially random. Hence, compression of the file is unlikely to reduce its size. By contrast, the C source code of the program has entropy of about 4.9 bits per character, indicating that optimal compression of the file would reduce its size by 38%. [Hamming, pp. 104–108]
  30. .SS "Chi-square Test"
  31. The chi-square test is the most commonly used test for the randomness of data, and is extremely sensitive to errors in pseudorandom sequence generators. The chi-square distribution is calculated for the stream of bytes in the file and expressed as an absolute number and a percentage which indicates how frequently a truly random sequence would exceed the value calculated. We interpret the percentage as the degree to which the sequence tested is suspected of being non-random. If the percentage is greater than 99% or less than 1%, the sequence is almost certainly not random. If the percentage is between 99% and 95% or between 1% and 5%, the sequence is suspect. Percentages between 90% and 95% and 5% and 10% indicate the sequence is “almost suspect”. Note that our JPEG  file, while very dense in information, is far from random as revealed by the chi-square test.
  33. Applying this test to the output of various pseudorandom sequence generators is interesting. The low-order 8 bits returned by the standard Unix \fBrand\fP() function, for example, yields:
  35.     Chi square distribution for 500000 samples is 0.01, and randomly would exceed this value more than 99.99 percent of the times.
  37. While an improved generator [Park & Miller] reports:
  39.     Chi square distribution for 500000 samples is 212.53, and randomly would exceed this value 97.53 percent of the times.
  41. Thus, the standard Unix generator (or at least the low-order bytes it returns) is unacceptably non-random, while the improved generator is much better but still sufficiently non-random to cause concern for demanding applications. Contrast both of these software generators with the chi-square result of a genuine random sequence created by timing radioactive decay events (http://www.fourmilab.ch/hotbits/).
  43.     Chi square distribution for 500000 samples is 249.51, and randomly would exceed this value 40.98 percent of the times.
  45. See [Knuth, pp. 35–40] for more information on the chi-square test. An interactive chi-square calculator is available at http://www.fourmilab.ch/rpkp/experiments/analysis/chiCalc.html.
  47. .SS "Arithmetic Mean"
  48. This is simply the result of summing the all the bytes (bits if the \fB-b\fP option is specified) in the file and dividing by the file length. If the data are close to random, this should be about 127.5 (0.5 for \fB-b\fP option output). If the mean departs from this value, the values are consistently high or low.
  50. .SS "Monte Carlo Value for Pi"
  51. Each successive sequence of six bytes is used as 24 bit X and Y co-ordinates within a square. If the distance of the randomly-generated point is less than the radius of a circle inscribed within the square, the six-byte sequence is considered a "hit". The percentage of hits can be used to calculate the value of Pi. For very large streams (this approximation converges very slowly), the value will approach the correct value of Pi if the sequence is close to random. A 500000 byte file created by radioactive decay yielded:
  53.     Monte Carlo value for Pi is 3.143580574 (error 0.06 percent).
  55. .SS "Serial Correlation Coefficient"
  56. This quantity measures the extent to which each byte in the file depends upon the previous byte. For random sequences, this value (which can be positive or negative) will, of course, be close to zero. A non-random byte stream such as a C program will yield a serial correlation coefficient on the order of 0.5. Wildly predictable data such as uncompressed bitmaps will exhibit serial correlation coefficients approaching 1. See [Knuth, pp. 64–65] for more details.
  58. .TP
  59. .B -b
  60. The input is treated as a stream of bits rather than of 8-bit bytes. Statistics reported reflect the properties of the bitstream.
  61. .TP
  62. .B -c
  63. Print a table of the number of occurrences of each possible byte (or bit, if the \fB-b\fP option is also specified) value, and the fraction of the overall file made up by that value. Printable characters in the ISO 8859-1 Latin-1 character set are shown along with their decimal byte values. In non-terse output mode, values with zero occurrences are not printed.
  64. .TP
  65. .B -f
  66. Fold upper case letters to lower case before computing statistics. Folding is done based on the ISO 8859-1 Latin-1 character set, with accented letters correctly processed.
  67. .TP
  68. .B -t
  69. Terse mode: output is written in Comma Separated Value (CSV) format, suitable for loading into a spreadsheet and easily read by any programming language. See \fBTERSE MODE OUTPUT FORMAT\fP below for additional details.
  70. .TP
  71. .B -u
  72. Print how-to-call information.
  74. .SH FILES
  75. If no \fIinfile\fP is specified, \fBent\fP obtains its input from standard input. Output is always written to standard output.
  78. Terse mode is selected by specifying the \fB-t\fP option on the command line. Terse mode output is written in Comma Separated Value (CSV) format, which can be directly loaded into most spreadsheet programs and is easily read by any programming language. Each record in the CSV file begins with a record type field, which identifies the content of the following fields. If the \fB-c\fP option is not specified, the terse mode output will consist of two records, as follows:
  80. 0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
  81. .br
  82. 1,\fIfile_length\fP,\fIentropy\fP,\fIchi_square\fP,\fImean\fP,\fIPi_value\fP,\fIcorrelation\fP
  84. where the italicised values in the type 1 record are the numerical values for the quantities named in the type 0 column title record. If the \fB-b\fP option is specified, the second field of the type 0 record will be "File-bits", and the \fIfile_length\fP field in type 1 record will be given in bits instead of bytes. If the \fB-c\fP option is specified, additional records are appended to the terse mode output which contain the character counts:
  86. 2,Value,Occurrences,Fraction
  87. .br
  88. 3,\fIv\fP,\fIcount\fP,\fIfraction\fP
  89. .br
  90. .I ...
  92. If the \fB-b\fP option is specified, only two type 3 records will appear for the two bit values v=0 and v=1. Otherwise, 256 type 3 records are included, one for each possible byte value. The second field of a type 3 record indicates how many bytes (or bits) of value v appear in the input, and \fIfraction\fP gives the decimal fraction of the file which has value v (which is equal to the \fIcount\fP value of this record divided by the \fIfile_length\fP field in the type 1 record).
  94. .SH BUGS
  95. Note that the "optimal compression" shown for the file is computed from the byte- or bit-stream entropy and thus reflects compressibility based on a reading frame of the chosen width (8-bit bytes or individual bits if the \fB-b\fP option is specified). Algorithms which use a larger reading frame, such as the Lempel-Ziv [Lempel & Ziv] algorithm, may achieve greater compression if the file contains repeated sequences of multiple bytes.
  97. .SH SEE ALSO
  99. Introduction to Probability and Statistics (http://www.fourmilab.ch/rpkp/experiments/statistics.html).
  101. [Hamming]
  102.     Hamming, Richard W. "Coding and Information Theory". Englewood Cliffs NJ: Prentice-Hall, 1980.
  104. [Knuth]
  105.     Knuth, Donald E. "The Art of Computer Programming, Volume 2 / Seminumerical Algorithms". Reading MA: Addison-Wesley, 1969. ISBN 0-201-89684-2.
  107. [Lempel & Ziv]
  108.     Ziv J. and A. Lempel. "A Universal Algorithm for Sequential Data Compression". IEEE Transactions on Information Theory 23, 3, pp. 337-343.
  110. [Park & Miller]
  111.     Park, Stephen K. and Keith W. Miller. "Random Number Generators: Good Ones Are Hard to Find". Communications of the ACM, October 1988, p. 1192.
  113. .SH AUTHOR
  114. John Walker (http://www.fourmilab.ch/)
RAW Paste Data