Sha256: de3f2e41d6f9e959db28321351b2fa4ef04b957b269e63d79c917acab6131af3

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path('../../common', __FILE__)

require 'drone/utils/uniform_sample'
include Drone

describe 'EWMA' do
  describe "A sample of 100 out of 1000 elements" do
    before do
      Drone::init_drone()
      
      @population = (0...1000)
      @sample = UniformSample.new('id1', 100)
      @population.step(1){|n| @sample.update(n) }
    end

    should "have 100 elements" do
      @sample.size.should == 100
      @sample.values.size.should == 100
    end

    should "only have elements from the population" do
      arr = @sample.values - @population.to_a
      arr.should == []
    end
  end
  
  describe "A sample of 100 out of 10 elements" do
    before do
      @population = (0...10)
      @sample = UniformSample.new('id1', 100)
      @population.step(1){|n| @sample.update(n) }
    end

    should "have 10 elements" do
      @sample.size.should == 10
      @sample.values.size.should == 10
    end

    should "only have elements from the population" do
      arr = @sample.values - @population.to_a
      arr.should == []
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
drone-1.0.10 specs/utils/uniform_sample_spec.rb
drone-1.0.9 specs/utils/uniform_sample_spec.rb
drone-1.0.8 specs/utils/uniform_sample_spec.rb
drone-1.0.7 specs/utils/uniform_sample_spec.rb
drone-1.0.6 specs/utils/uniform_sample_spec.rb
drone-1.0.5 specs/utils/uniform_sample_spec.rb
drone-1.0.4 specs/unit/uniform_sample_spec.rb
drone-1.0.1 specs/unit/uniform_sample_spec.rb