Sha256: e754091d9553172e3cde13bccf944ff67688673d4842fe8af91b950f688c6220
Contents?: true
Size: 434 Bytes
Versions: 2
Compression:
Stored size: 434 Bytes
Contents
# frozen_string_literal: true module SVMKit # @!visibility private module Utils module_function # @!visibility private def choice_ids(size, probs, rng=nil) rng ||= Random.new Array.new(size) do target = rng.rand chosen = 0 probs.each_with_index do |p, idx| break (chosen = idx) if target <= p target -= p end chosen end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
svmkit-0.7.2 | lib/svmkit/utils.rb |
svmkit-0.7.1 | lib/svmkit/utils.rb |