To check the randomness of a series of bits using this repository, you can use the IID or non-IID entropy assessment tools depending on whether you assume your data source is IID (independent and identically distributed). Below are the steps and commands to perform the randomness check.
Steps to Check Randomness
Compile the Tools:
Navigate to the cpp directory in the repository.
Use the provided Makefile to compile the tools. For example:
bash
make iid
make non_iid
This will generate the executables ea_iid and ea_non_iid.
Prepare Your Data:
Ensure your data is in binary format (raw bytes). The repository expects the input file to contain symbols (e.g., bits or bytes) packed into 8-bit values.
<file_name>: The path to your binary file containing the data to be tested.
[bits_per_symbol]: The number of bits per symbol in your data (1–8). For example:
If testing raw bits, use 1.
If testing bytes, use 8.
-i: Initial entropy estimate for unconditioned data (default).
-c: Entropy estimate for conditioned sequential datasets (bitstrings only).
-a: Use all read bits for the H_bitstring assessment.
-t: Truncate the data to the first 1,000,000 bits for the H_bitstring assessment.
-v: Verbose mode for detailed output. Use multiple -v for more detail.
-l <index>,<samples>: Test a subset of the file. Reads samples starting at index * samples bytes.
Example Usage
Using the IID Tool:
If you have a file data.bin with 1-bit symbols (e.g., raw binary bits) and want an initial entropy estimate, run:
bash
./ea_iid -i -a -v data.bin 1
If the data contains 8-bit symbols (e.g., bytes), use:
bash
./ea_iid -i -a -v data.bin 8
Using the Non-IID Tool:
For the same file data.bin with 1-bit symbols, run:
bash
./ea_non_iid -i -a -v data.bin 1
For 8-bit symbols:
bash
./ea_non_iid -i -a -v data.bin 8
Interpreting the Results
Min-Entropy Estimate:
Both tools provide a min-entropy estimate (H_min) in bits per symbol. This is the measure of unpredictability or randomness.
A higher value (closer to the number of bits per symbol) indicates better randomness. For example:
A 1-bit symbol should have a min-entropy close to 1.
An 8-bit symbol should have a min-entropy close to 8.
Verbose Output:
Use -v to see detailed results for individual tests (e.g., Most Common Value Test, Collision Test, etc.).
The lowest min-entropy value across all tests is considered the entropy estimate.
Sufficient Randomness:
IID data: The min-entropy should approach the theoretical maximum (e.g., 1 for 1-bit symbols, 8 for 8-bit symbols).
Non-IID data: The min-entropy will likely be lower due to correlations or patterns, but it should still be high relative to the number of bits per symbol.
How to Decide if It's Sufficiently Random
Compare the min-entropy value (H_min) to the number of bits per symbol:
1-bit symbols: H_min close to 1 indicates sufficient randomness.
8-bit symbols: H_min close to 8 indicates sufficient randomness.
If the min-entropy is much lower than the number of bits per symbol, the data may not be sufficiently random.
Verbose mode (-v) provides insights into specific issues (e.g., patterns or biases in the data).