Created
October 25, 2019 18:00
-
-
Save bakineggs/9f0d7166b0cc43cc869e3562b5dd338c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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