Skip to main content
7 of 9
Polish
fgrieu
  • 145.5k
  • 12
  • 319
  • 611

The question really asks for sample of data from a source with a known entropy rate.


I suggest to start with the simplest: sources with zero entropy rate. Examples from which the first megabytes can be readily obtained:

  • a source producing only bytes at zero.
  • a source cycling over the 256 bytes incrementally.
  • a source consisting of the SHA-256 hashes of bytestrings of increasing length, in lexicographic order.
  • /dev/random or /dev/urandom modified to replace the input of their built-in PRNG with zeroes.
  • a source producing the bytes of $\pi$ (e.g. using Bellard's method).

NIST SP 800-90B tests won't help distinguish the last three from a source with some entropy. That illustrates these (or similar) tests can't reliably detect even a total lack of entropy, unless some hypothesis is made on the nature of the source.


We can use a lightly conditioned source. It's easy to make one from a microphone in front of something emitting noise (a fan will do), sampled by an ADC (sound input of a PC will do), and the bytes from some number of samples fed thru some light conditioning (like: group $n$ 16-bit samples and output the sum modulo 256 of the $2n$ bytes). That's a better fit for what NIST SP 800-90 is designed to work on. It'll be interesting to see how $n$ influences the results. This source doesn't have a know entropy rate, though.


We can manufacture a source with independent bytes and a known biased distribution leading to (at most) a certain known entropy. One way is to take /dev/urandom (or any source which output can't be discerned from that of a perfect true random source), group bytes by two to form an integer in $[0\ldots2^{16})$, and output the high-order byte of that unless the integer is less than $k$, for some parameter $k\in[0\ldots2^8]$. This leads to a source with byte zero having probability $(2^8-k)/(2^{16}-k)$, and the others $2^8/(2^{16}-k)$. Entropy in bit/byte is easy to compute as a function of $k$, and goes (for $k$ up to $100$): Entropy in bit/byte

fgrieu
  • 145.5k
  • 12
  • 319
  • 611