Class: Spark::Command::Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/spark/command/statistic.rb

Overview


Sample

Instance Method Summary collapse

Instance Method Details

#_samplerObject



23
24
25
26
27
28
29
30
31
# File 'lib/spark/command/statistic.rb', line 23

def _sampler
  if @with_replacement
    sampler = Spark::Sampler::Poisson
  else
    sampler = Spark::Sampler::Uniform
  end

  sampler = sampler.new(@fraction, @seed)
end

#lazy_run(iterator, _) ⇒ Object



15
16
17
# File 'lib/spark/command/statistic.rb', line 15

def lazy_run(iterator, _)
  sampler.lazy_sample(iterator)
end

#run(iterator, _) ⇒ Object



11
12
13
# File 'lib/spark/command/statistic.rb', line 11

def run(iterator, _)
  sampler.sample(iterator)
end

#samplerObject



19
20
21
# File 'lib/spark/command/statistic.rb', line 19

def sampler
  @sampler ||= _sampler
end