Method: FeldtRuby::Optimize::PopulationSampler#sample_indices_without_replacement
- Defined in:
- lib/feldtruby/optimize/optimizer.rb
#sample_indices_without_replacement(numSamples, indices) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/feldtruby/optimize/optimizer.rb', line 118 def sample_indices_without_replacement(numSamples, indices) sampled_indices = [] size = indices.length numSamples.times do |i| index = i + rand_int(size - i) sampled_index, skip = indices.swap!(i, index) sampled_indices << sampled_index end sampled_indices end |