From 20f394a452e425f4bdad0195637612499575a878 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 14 Feb 2023 17:39:40 +0100 Subject: [PATCH] random: add a commented-out test i used to run ENT https://www.fourmilab.ch/random/ Entropy = 8.000000 bits per byte. Optimum compression would reduce the size of this 912444480 byte file by 0 percent. Chi square distribution for 912444480 samples is 254.09, and randomly would exceed this value 50.43 percent of the times. Arithmetic mean value of data bytes is 127.4952 (127.5 = random). Monte Carlo value for Pi is 3.141641048 (error 0.00 percent). Serial correlation coefficient is 0.000022 (totally uncorrelated = 0.0). --- src/random.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/random.rs b/src/random.rs index 6b15182d..b433ac2a 100644 --- a/src/random.rs +++ b/src/random.rs @@ -109,4 +109,20 @@ mod tests { set.insert(rand); } } + + // I used this to perform statistical tests of the random generation function using ENT + // (https://fourmilab.ch/random/). + //#[test] + //fn write_to_file() { + //use std::io::Write; + //let mut f = std::fs::OpenOptions::new() + //.write(true) + //.create(true) + //.append(true) + //.open("random_out") + //.unwrap(); + //for _ in 0..10_000_000 { + //f.write(&random_bytes().unwrap()).unwrap(); + //} + //} }