-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
- Weighted sample
class Hash
def wsample
max_by { |_, w|
next -Float::INFINITY if w == 0
rand**(1.0 / w)
}&.first # first to return just the key
end
def wsample_strict
total_probability = values.sum
raise ArgumentError, "Weights must add up to 1, but they add up to #{total_probability}." if total_probability != 1
wsample
end
end- bresenham's line
- @canvas.draw_line/draw_rect_outline
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels