timocratic (owner)

Revisions

gist: 89887 Download_button fork
public
Public Clone URL: git://gist.github.com/89887.git
Embed All Files: show embed
assign_by_prob.rb #
1
2
3
4
5
6
7
def assign_by_weight(weights)
  sum = weights.keys.inject(0) { |s,v| s += v }
  #normalize random over sum
  #parse weights into some form of mutually exclusive set
  return result
end
foo = assign_by_weight(0.5 => :foo, 0.6 => :bar)