Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct default p-value in testu01. #34

Merged
merged 2 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ Supported bitgenerators include: `PCG64`, `Philox4x64`, `Xoshiro256`, `ChaCha` a

## Empirical Randomness Testing
Running the test suite provided by [TestU01][6] on the supported generators is supported.
To build the test executable one needs to run `dune build bin`. To see the available
command options run `dune exec -- crush -help`. Below is a sample output from running
`dune exec -- crush pcg64` to test `PCG64` on the Small Crush test suite:
To see the available commandline options run `dune exec -- ./bin/crush.exe -help`.
Below is a sample output from running `dune exec -- ./bin/crush.exe -name smallcrush pcg64`
to test `PCG64` on the Small Crush test suite:
```shell
$ dune exec -- crush pcg64

========= Summary results of SmallCrush =========

Version: TestU01 1.2.3
Expand All @@ -101,8 +99,8 @@ $ dune exec -- crush pcg64
```
## Benchmarks
A utility to compare the performance of each bitgenerator's `next_uint64` function is provided.
To compile the benchmark executor run `dune build bin`, and then run it using `dune exec -- bench`.
Once the benchmark run has completed, a summary table will be displayed in stdout.
Run the microbenchmark using `dune exec -- ./bin/bench.exe` and once it has completed,
a summary table will be displayed in stdout.


[1]: https://codecov.io/gh/zoj613/bitgenerators/graph/badge.svg?token=KOOG2Y1SH5
Expand Down
19 changes: 8 additions & 11 deletions bin/crush.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ let rev_bits v =
all the 64-bit PRNG's which outputs the the high and then low 32 bits of the
unsigned random 64 bits. *)
let make_int32 (module M : S) ~rev =
let ss = SeedSequence.initialize [] in
let t = ref (M.initialize ss) in
let bits () = match M.next_uint32 !t, rev with
| (u, t'), false -> t := t'; Uint32.to_int32 u
| (u, t'), true -> t := t'; rev_bits u |> Uint32.to_int32
in
bits
let t = SeedSequence.initialize [] |> M.initialize |> ref in
let bits () = match M.next_uint32 !t with
| u, t' -> t := t'; rev u |> Uint32.to_int32
in bits


let to_module = function
Expand Down Expand Up @@ -71,7 +68,6 @@ let usage = "
Run TestU01's test suite on the supported bitgenerators.
It offers several batteries of tests including 'Small Crush'
(which consists of 10 tests), 'Crush' (96 tests), and 'Big Crush' (106 tests).
Bitgenerators to select from include: sfc64, philox64, pcg64 and xoshiro256.

crush [-name] [-pvalue] [-rev] [-verbose] <bitgen>

Expand All @@ -80,19 +76,20 @@ E.g `crush -name bigcrush -rev pcg64` (which runs Big Crush on the reversed bits


let () =
let pvalue = ref 0.01
let pvalue = ref 0.001
and test = ref "smallcrush"
and prng = ref ""
and verbose = ref false
and rev = ref false in
let spec = [
("-pvalue", Arg.Set_float pvalue, "Threshold for suspect p-values. Defaults to 0.01");
("-pvalue", Arg.Set_float pvalue, "Threshold for suspect p-values. Defaults to 0.001");
("-name", Arg.Set_string test, "Name of the test to run. Should be one of {smallcrush, crush, bigcrush}. Defaults to 'smallcrush'");
("-rev", Arg.Set rev, "Run tests on reversed bits of the input.");
("-verbose", Arg.Set verbose, "In addition to the summary report, write the result of each test to stdout.");
] in
Arg.parse spec (fun x -> prng := x) usage;
TestU01.Swrite.set_basic !verbose;
Probdist.Gofw.set_suspectp !pvalue;
TestU01.Unif01.create_extern_gen_int32 (is_rev !prng !rev) (to_module !prng |> make_int32 ~rev:!rev)
(to_module !prng |> make_int32 ~rev:(if !rev then rev_bits else Fun.id))
|> TestU01.Unif01.create_extern_gen_int32 (is_rev !prng !rev)
|> testsuite !test
Loading