fix number of bins: yet another off-by-one main
authortomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 15:58:40 +0000 (16:58 +0100)
committertomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 15:58:40 +0000 (16:58 +0100)
coinflip-histo.py

index 2a737ce2b8689988a8d29d3ac284ce64f5637e71..65c8a44581fa4000b9ac00ebbc6ea2ce7c04a379 100755 (executable)
@@ -16,5 +16,6 @@ repeats = int(sys.argv[2])
 
 vals = [sum(flipcoins(flips)) for i in range(repeats)]
 
-plot.hist(vals, bins=flips, align='left')
+# The number of bins must be flips+1: why?
+plot.hist(vals, bins=flips+1, align='left')
 plot.show()