Diceroll

Source ยป Wikipedia

Diceroll is a program used to generate random numbers with a few useless(-ish) features. This program takes advantage of Boost's program options library.

Code was tested on Linux and compiled with g++ version 7.1.1. In order to compile you may have to use the -lboost_program_options flag. If you need to generate a load of random numbers, using -O3 may help you.

diceroll.cpp

Example output

$ ./diceroll -p 5
0.27974
$ ./diceroll -n 100 -q --stat-all
min: 0.002179719051425401419
max: 0.977375478786662777462
median: 0.398437007011534366713
avg: 0.447476069991333935683
variance: 0.083249162000595136032
standard deviation: 0.288529308737596250502
coefficient of variation: 0.644792712028565160177
$ ./diceroll -n 10 --prefix 0.0001 --numbers-force
0.000107049545138513660
0.000143470444088610049
0.000147587322070482556
0.000139974264783565420
0.000181840486508422802
0.000160187321078831657
0.000162660698361068374
0.000128797573377098615
0.000174211224657959895
0.000110155040369495200

Why -g badrandom (std::rand) is bad:

$ for run in {1..3};do ./diceroll -n 2 -g badrandom;echo; done
0.735870394732742754155
0.633142639246370009752

0.735870394732742754155
0.633142639246370009752

0.735870394732742754155
0.633142639246370009752

$ for run in {1..3};do ./diceroll -n 2;echo; done
0.949858597491534347541
0.428885024200160522008

0.570460045097155726292
0.776410311903654044667

0.063175945874337505832
0.978945931156750787463