Skip to content

Instantly share code, notes, and snippets.

@kei-s
Created January 6, 2010 18:51
Show Gist options
  • Save kei-s/270523 to your computer and use it in GitHub Desktop.
Save kei-s/270523 to your computer and use it in GitHub Desktop.
custom random funciton
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