Skip to content

Instantly share code, notes, and snippets.

@uokesita
Created October 12, 2013 03:47
Show Gist options
  • Save uokesita/6945587 to your computer and use it in GitHub Desktop.
Save uokesita/6945587 to your computer and use it in GitHub Desktop.
1.8.7 :064 > obj = [34773, 28566, 31509, 24366, 32891, 32230, 29208, 24501, 32027, 31359, 27217, 31430, 28049, 35981, 34471, 33724, 30934, 35097, 29596, 31871, 31603, 33786, 33399]
=> [34773, 28566, 31509, 24366, 32891, 32230, 29208, 24501, 32027, 31359, 27217, 31430, 28049, 35981, 34471, 33724, 30934, 35097, 29596, 31871, 31603, 33786, 33399]
1.8.7 :065 > total = 718588 => 718588
1.8.7 :066 > list = obj.map{ | x | "%4f" % (1 - (BigDecimal("#{x}")/BigDecimal("#{total}"))) }
=> ["0.951609", "0.960247", "0.956152", "0.966092", "0.954228", "0.955148", "0.959354", "0.965904", "0.955431", "0.956360", "0.962124", "0.956261", "0.960967", "0.949928", "0.952030", "0.953069", "0.956952", "0.951158", "0.958814", "0.955648", "0.956021", "0.952983", "0.953521"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment