probabilities = {
    => 1/5.0,
     => 1/6.0,
    => 1/7.0,
   => 1/8.0,
       => 1/9.0,
      => 1/10.0,
    => 1/11.0,
}
probabilities[] = 1.0 - probabilities.each_value.inject(:+)
ordered_keys = probabilities.keys

sum, sums = 0.0, {}
ordered_keys.each do |key|
  sum += probabilities[key]
  sums[key] = sum
end

actual = Hash.new(0)

samples = 1_000_000
samples.times do
  r = rand
  for k in ordered_keys
    if r < sums[k]
      actual[k] += 1
      break
    end
  end
end

puts  
for k in ordered_keys
  act = Float(actual[k]) / samples
  val = probabilities[k]
  printf , k, val, act, 100*(act-val)/val
end