Created
January 6, 2010 18:51
-
-
Save kei-s/270523 to your computer and use it in GitHub Desktop.
custom random funciton
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
include Math | |
def custom(u) | |
u < 0.5 ? 0.5-sqrt(0.25-u/2.0) : sqrt(u/2.0-0.25)+0.5 | |
end | |
(0..200000).map { | |
custom(rand()) | |
}.group_by{|num| ((num*20).floor % 20)}.sort_by{|k,v| k}.each{|k,v| | |
puts "#{"%2d" % k} #{"*"*(v.size/500)} #{v.size}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment