Skip to content

Instantly share code, notes, and snippets.

@bakineggs
Created October 25, 2019 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakineggs/9f0d7166b0cc43cc869e3562b5dd338c to your computer and use it in GitHub Desktop.
Save bakineggs/9f0d7166b0cc43cc869e3562b5dd338c to your computer and use it in GitHub Desktop.
arr = (0...20).to_a
p0 = 0
(0..8).each do |x|
p0 += 0.475 ** x * 0.525 ** (20 - x) * arr.combination(x).count
end
p1 = 0.475 ** 9 * 0.525 ** 11 * arr.combination(9).count
p2 = 0
(10..20).each do |x|
p2 += 0.475 ** x * 0.525 ** (20 - x) * arr.combination(x).count
end
puts "p0 = #{p0}"
puts "p1 = #{p1}"
puts "p2 = #{p2}"
puts "sum = #{p0 + p1 + p2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment