Sha256: ece136df76da2f9d243bfaba9eb8814f86e02cf748663e668fa27117b059df6c

Contents?: true

Size: 359 Bytes

Versions: 15

Compression:

Stored size: 359 Bytes

Contents

module WBench
  class Stats < SimpleDelegator
    def median
      sort[length / 2]
    end

    def sum
      inject(:+)
    end

    def mean
      sum / length.to_f
    end

    def sample_variance
      (inject(0) { |variance, value| variance + ((value - mean) ** 2) }) / length
    end

    def std_dev
      Math.sqrt(sample_variance)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wbench-1.1.1 lib/wbench/stats.rb
wbench-1.1.0 lib/wbench/stats.rb
wbench-1.0.0 lib/wbench/stats.rb
wbench-0.4.0 lib/wbench/stats.rb
wbench-0.3.7 lib/wbench/stats.rb
wbench-0.3.6 lib/wbench/stats.rb
wbench-0.3.5 lib/wbench/stats.rb
wbench-0.3.4 lib/wbench/stats.rb
wbench-0.3.3 lib/wbench/stats.rb
wbench-0.3.2 lib/wbench/stats.rb
wbench-0.3.1 lib/wbench/stats.rb
wbench-0.3.0 lib/wbench/stats.rb
wbench-0.2.3 lib/wbench/stats.rb
wbench-0.2.2 lib/wbench/stats.rb
wbench-0.2.1 lib/wbench/stats.rb