Class: Spark::Sampler::Uniform
- Inherits:
-
Base
- Object
- Base
- Spark::Sampler::Uniform
show all
- Defined in:
- lib/spark/sampler.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
#fraction, #seed
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#lazy_sample(iterator) ⇒ Object
79
80
81
82
83
|
# File 'lib/spark/sampler.rb', line 79
def lazy_sample(iterator)
iterator.select do |item|
rng.rand <= fraction
end
end
|
#rng ⇒ Object
85
86
87
|
# File 'lib/spark/sampler.rb', line 85
def rng
@rng ||= Random.new(seed)
end
|
#sample(iterator) ⇒ Object
74
75
76
77
|
# File 'lib/spark/sampler.rb', line 74
def sample(iterator)
iterator.select!{|item| rng.rand <= fraction}
iterator
end
|