Guest User

Untitled

a guest
May 23rd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. MATCH = 0.1
  2. NO_MATCH = 0.9
  3.  
  4. percentages = [
  5. NO_MATCH**4,
  6. NO_MATCH**3 * MATCH * 4,
  7. NO_MATCH**2 * MATCH**2 * 6, # 12, 13, 14, 23, 24, 34
  8. NO_MATCH * MATCH**3 * 4,
  9. MATCH**4
  10. ]
  11.  
  12. sum = 0.0
  13. percentages.each_with_index do |pct, matches|
  14. puts "%d matches %.2f%% of the time averages %.2f matched (%d matchings)" % [matches, pct, matches * pct, pct * 10000 * 10000]
  15. sum += pct * matches
  16. end
  17. puts sum
  18.  
  19. ## Output
  20.  
  21. 0 matches 0.66% of the time averages 0.00 matched (65610000 matchings)
  22. 1 matches 0.29% of the time averages 0.29 matched (29160000 matchings)
  23. 2 matches 0.05% of the time averages 0.10 matched (4860000 matchings)
  24. 3 matches 0.00% of the time averages 0.01 matched (360000 matchings)
  25. 4 matches 0.00% of the time averages 0.00 matched (10000 matchings)
  26. 0.4
Add Comment
Please, Sign In to add comment