Class Benelux::Stats::Group

  1. lib/benelux/stats.rb
Parent: Array

Methods

public instance

  1. +
  2. <<
  3. []
  4. filter
  5. max
  6. mean
  7. merge
  8. min
  9. n
  10. sample
  11. sd
  12. sum
  13. sumsq
  14. tag_values
  15. tags

Included modules

  1. Selectable

Attributes

name [RW]

Public instance methods

+ (other)
[show source]
    # File lib/benelux/stats.rb, line 66
66:       def +(other)
67:         unless @name == other.name
68:           raise BeneluxError, "Cannot add #{other.name} to #{@name}"
69:         end
70:         g = Group.new self
71:         g.name = @name
72:         g << other
73:         g
74:       end
<< (other)
[show source]
    # File lib/benelux/stats.rb, line 76
76:       def <<(other)
77:         self.push *other
78:         self
79:       end
[] (*tags)

Alias for filter

filter (*tags)
[show source]
     # File lib/benelux/stats.rb, line 116
116:       def filter(*tags)
117:         (f = super).name = @name
118:         f
119:       end
max ()
[show source]
     # File lib/benelux/stats.rb, line 110
110:       def max()     merge.max    end
mean ()
[show source]
     # File lib/benelux/stats.rb, line 108
108:       def mean()    merge.mean   end
merge (*tags)
[show source]
    # File lib/benelux/stats.rb, line 81
81:       def merge(*tags)
82:         #tags = Selectable.normalize tags
83:         mc = Calculator.new
84:         mc.init_tags!
85:         all = tags.empty? ? self : self.filter(tags)
86:         all.each { |calc| 
87:           mc.merge! calc
88:           mc.add_tags_quick calc.tags
89:         }    
90:         mc
91:       end
min ()
[show source]
     # File lib/benelux/stats.rb, line 109
109:       def min()     merge.min    end
n ()
[show source]
     # File lib/benelux/stats.rb, line 114
114:       def n()       merge.n      end
sample (s, tags={})
[show source]
     # File lib/benelux/stats.rb, line 93
 93:       def sample(s, tags={})
 94:         raise BeneluxError, "tags must be a Hash" unless Hash === tags
 95:         c = Calculator.new
 96:         c.add_tags tags
 97:         c.sample s
 98:         self << c
 99:         nil
100:       end
sd ()
[show source]
     # File lib/benelux/stats.rb, line 113
113:       def sd()      merge.sd     end
sum ()
[show source]
     # File lib/benelux/stats.rb, line 112
112:       def sum()     merge.sum    end
sumsq ()
[show source]
     # File lib/benelux/stats.rb, line 111
111:       def sumsq()   merge.sumsq  end
tag_values (tag)
[show source]
     # File lib/benelux/stats.rb, line 102
102:       def tag_values(tag)
103:         vals = self.collect { |calc| calc.tags[tag] }
104:         Array.new vals.uniq
105:       end
tags ()
[show source]
     # File lib/benelux/stats.rb, line 107
107:       def tags()    merge.tags   end