3 ms·
> alias coindecide='if (( RANDOM % 2 == 0 )); then echo Yes; else echo No; fi' I would probably (put intended) not use that. IANAS[tatistician] but I'm seeing
by kazinator 3y ago
> alias coindecide='if (( RANDOM % 2 == 0 )); then echo Yes; else echo No; fi'
I would probably (put intended) not use that. IANAS[tatistician] but I'm seeing suspicious runs of 1's or 0's which have a low probability:
$ for x in $(seq 1 10); do echo $((RANDOM % 2)); done
1
1
1
1
1
1
0
1
1
0
$ for x in $(seq 1 10); do echo $((RANDOM % 2)); done
0
1
1
0
0
0
0
0
0
1
$ for x in $(seq 1 10); do echo $((RANDOM % 2)); done
1
0
1
1
1
1
1
1
1
1
$ echo $BASH_VERSION # on Ubuntu 18.04, x86-64
4.4.20(1)-release
If this is just an interactive thing you run manually, you may be better off tossing an actual coin.
- mg 3y agoIf there are runs of zeros, this should result in a number greater than 25000: for i in {1..100000}; do echo $((RANDOM % 2))$((RANDOM % 2)); done | grep 00 | wc For me, it always comes out very close to 25000.
- kazinator 3y agoHmm. I also tried this with four bit codes: $ for x in $(seq 1 1600000); do \ echo $((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2))$((RANDOM % 2)); \ done | awk ' { hist[$0]++ } END { for (code in hist) print code, hist[code] }' 0100 99668 0101 99832 0110 100026 0111 99837 0000 99899 0001 100451 0010 99846 0011 99980 1000 100246 1001 100182 1010 100116 1011 100383 1100 100014 1101 99470 1110 99535 1111 100515 Doesn't seem like anything deviates too much. If there were excessive runs of 1's and 0's, the 1111 and 0000 codes would be excessively frequent.