Spectra Logo

Spectra

       Platform: GNU/Linux
       Language: C
       License: GPLv2
       Dependencies: GD, libpng
       Development Progress: (github)
       Latest Stable Release: 1.3 (Download)

About

       Spectra is a very simple tool I have written to aid in the development and testing of random number generators. By visualizing random data, Spectra is able to help detect repeating patterns in streams of random data by using the most powerful computer in the known world, your brain. Spectra first generates an image based on the data contained in the input file, and then counts the occurrences of each ASCII character. While this is by no means an exhaustive examination of the data, it does give you a reference point when working with ASCII files.

Usage

       Using Spectra is very simple, you just give it an input file and wait a few seconds. Ideally you should give it width and height dimensions to use for the generated image with the "-x" and "-y" options respectively, but even that is optional. Just understand that the smaller the image, the less accurate the results will be. The default image size is 640x480, which gives you a sample size of 307,200 digits, which is not a whole lot in the statistical sense. Comparatively, if you give that HDTV of yours a workout and generate an image at 1920x1080, you will have analyzed 2,073,600 digits, a much more respectable number. Processing time is very slight even on low-end hardware, so don't be afraid to aim high.

For a quick example, let's see what we get when we put a sample ASCII file from Random.org:

bash:~# spectra -i ./2009-11-08.txt 
Spectra - Version 1.0
---------------------------
Opening input file: ./2009-11-08.txt...OK
Creating output file: output.png...OK
Dimensions: 640x480
Generating image...Done

Image Analysis
---------------------------
Occurrences out of 307200:
Character: 0 - 153955
Character: 1 - 154366
Closing files...
Flushing memory...
Done.
Here you can see that the occurrences look pretty close to equal, so we got a good look at the bias. As I said, with this small of a sample it is unwise to draw too many conclusions, but at least it isn't wildly skewed. Of course, the occurrence counts aren't the main attraction, so let's look at the output file itself:

Spectra Output 1

You can plainly see there is no discernible pattern in the image, which is another good sign. Spectra is also able to generate colored images if the input data contains ASCII values 0 to 9 rather than just 0 and 1. This can help with the visual identification of bias, though I imagine you need to have relatively good eyesight to make use of it. For instance, the red-yellowish overall look of this image shows the low-number bias found in early tests of bt_rng:

Spectra Output 2

For reference, here is an example of what a terrible RNG looks like. For this example I wrote up a quick program that got a random number between 0 and 9 with the standard rand() call, and depending on the number would write out 1 of 10 possible strings of 0's and 1's. So this is a (relatively) random data source, but being output with predictable patterns. Let's take a look:

Terrible RNG

If you ever see output like that on a production device or server: run away, quickly.

Downloads

Filename MD5 Size Date
spectra-1.3.tar.gz 7d80a07c793e9a4d69943b55f8b34625 76K 2012-07-16
spectra-1.2.tar.gz c92860e38659faa6f26a15c907633ccb 76K 2010-07-11
spectra-1.1.tar.gz 7c75166ef815e50b33150ca0108493a6 64K 2010-04-22
spectra-1.0.tar.gz 3c329d7ff30c24ab4ed796ae6c461ef9 64K 2010-03-10