ベンフォードの法則を確かめてみる
counts = [] (1..9).each {|i|counts[i] = 0} rndf = RandomFloat.new :gt_or_eq => 1, :lt => 10000 100000.times { counts[rndf.rand.to_s[0, 1].to_i] += 1 } (1..9).each {|i|print "%d %d\n" % [i, counts[i]]}
$ ruby19 random_float.rb 1 30194 2 16903 3 13305 4 9390 5 7751 6 6783 7 6451 8 4707 9 4516