Class: CAIterator
- Inherits:
-
Object
- Object
- CAIterator
- Defined in:
- lib/carray/iterator.rb
Overview
CAIterator -- the form-only base of the iterator family. It carries no engine: each family member (CASlabIterator / CAWindowIterator / CABlockIterator / CACategoricalIterator / CAGroupIterator) implements its own fast engine. The base declares two things: the shared form accessors over the @ndim / @shape ivars, and the common reduction surface every member must implement (surface uniformity is the value: "this is an iterator, so it must answer these").
shape is canonical; dim is a legacy alias. A member exposes what it
actually holds (source / reference / labels) and adds its own methods
(min_index / max_index / map / correlate / convolve / sort_addr / ...);
those are NOT part of the common contract because some members legitimately
omit them (a window has no map, a group has no within-piece min_index).
The 2.0 generic dispatch (calculate / filter / evaluate over a kernel_at_addr slot) was retired in 3.0.
Direct Known Subclasses
CABlockIterator, CACategoricalIterator, CAGroupIterator, CASlabIterator, CAWindowIterator
Instance Attribute Summary collapse
-
#ndim ⇒ Object
readonly
No
include Enumerable: the family surface is fully explicit per iterator, so Enumerable's reduction-like names (to_a / min / sum / count / ...) do not leak in and silently fold the pieces. -
#shape ⇒ Object
(also: #dim)
readonly
No
include Enumerable: the family surface is fully explicit per iterator, so Enumerable's reduction-like names (to_a / min / sum / count / ...) do not leak in and silently fold the pieces.
Instance Method Summary collapse
-
#accumulate ⇒ CArray
Returns the sum of each piece kept in the source's own
data_type, wrapping at its width, where #sum answers in the type the core promotes to (:float64for integers). -
#all ⇒ CArray
Returns whether every cell of each piece is true.
-
#any ⇒ CArray
Returns whether any cell of each piece is true.
-
#count(value = nil) ⇒ CArray
Returns a count per piece: with no argument the cells that are not masked, with
UNDEFthe masked cells, and with any other value the cells equal to it. -
#count_masked ⇒ CArray
Returns the number of masked cells of each piece.
-
#count_not_masked ⇒ CArray
Returns the number of cells of each piece that are not masked.
-
#cumcount ⇒ CArray
Returns a source-shaped array of the running count of cells that are not masked within each piece.
-
#cummax ⇒ CArray
Returns a source-shaped array of the running maximum within each piece.
-
#cummin ⇒ CArray
Returns a source-shaped array of the running minimum within each piece.
-
#cumprod ⇒ CArray
Returns a source-shaped array of the running product within each piece.
-
#cumsum ⇒ CArray
Returns a source-shaped array of the running sum within each piece.
-
#each {|piece| ... } ⇒ Enumerator, self
Yields each piece in turn as a CArray.
-
#elements ⇒ CArray
Returns the total number of cells in each piece, masked or not.
-
#map {|piece| ... } ⇒ CArray
Returns a source-shaped array built by applying the block to each piece and scattering the result back into that piece's cells.
-
#max ⇒ CArray
Returns the largest value in each piece.
-
#max_addr ⇒ CArray
Returns the flat address in the source of the largest value of each piece.
-
#max_index ⇒ CArray
Returns the position of the largest value within each piece.
-
#mean ⇒ CArray
Returns the arithmetic mean of each piece.
-
#median ⇒ CArray
Returns the median of each piece.
-
#min ⇒ CArray
Returns the smallest value in each piece.
-
#min_addr ⇒ CArray
Returns the flat address in the source of the smallest value of each piece -- which source cell holds it, rather than where it sits inside the piece.
-
#min_index ⇒ CArray
Returns the position of the smallest value within each piece.
-
#minmax ⇒ Array<CArray>
Returns the smallest and largest value of each piece, found in one pass.
-
#percentile(*pers) ⇒ CArray+
Returns the requested percentile(s) of each piece.
-
#prod ⇒ CArray
Returns the product of each piece.
-
#quantile ⇒ Array<CArray>
Returns the five-number summary of each piece,
[min, Q1, median, Q3, max]. -
#reduce(init = nil) {|acc, piece| ... } ⇒ Object
Folds the pieces with a block, for a reduction the family does not name.
-
#sort_addr ⇒ CArray
Returns a source-shaped array whose cells, read piece by piece, give the flat source addresses that put that piece in ascending order.
-
#stddev ⇒ CArray
Returns the sample standard deviation (divisor
n - 1) of each piece. -
#stddevp ⇒ CArray
Returns the population standard deviation (divisor
n) of each piece. -
#sum ⇒ CArray
Returns the sum of each piece.
-
#variance ⇒ CArray
Returns the sample variance (divisor
n - 1) of each piece. -
#variancep ⇒ CArray
Returns the population variance (divisor
n) of each piece. -
#wmean(weights) ⇒ CArray
Returns the weighted mean of each piece.
-
#wsum(weights) ⇒ CArray
Returns the weighted sum of each piece.
Instance Attribute Details
#ndim ⇒ Object (readonly)
No include Enumerable: the family surface is fully explicit per iterator,
so Enumerable's reduction-like names (to_a / min / sum / count / ...) do not
leak in and silently fold the pieces. A method outside the contract below
that a member does not define is a clean NoMethodError, not a wrong answer.
29 30 31 |
# File 'lib/carray/iterator.rb', line 29 def ndim @ndim end |
#shape ⇒ Object (readonly) Also known as: dim
No include Enumerable: the family surface is fully explicit per iterator,
so Enumerable's reduction-like names (to_a / min / sum / count / ...) do not
leak in and silently fold the pieces. A method outside the contract below
that a member does not define is a clean NoMethodError, not a wrong answer.
29 30 31 |
# File 'lib/carray/iterator.rb', line 29 def shape @shape end |
Instance Method Details
#accumulate ⇒ CArray
Returns the sum of each piece kept in the source's own data_type,
wrapping at its width, where #sum answers in the type the core
promotes to (:float64 for integers).
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#all ⇒ CArray
Returns whether every cell of each piece is true.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#any ⇒ CArray
Returns whether any cell of each piece is true.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#count(value = nil) ⇒ CArray
Returns a count per piece: with no argument the cells that are not
masked, with UNDEF the masked cells, and with any other value the
cells equal to it.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#count_masked ⇒ CArray
Returns the number of masked cells of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#count_not_masked ⇒ CArray
Returns the number of cells of each piece that are not masked.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#cumcount ⇒ CArray
Returns a source-shaped array of the running count of cells that are not masked within each piece.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#cummax ⇒ CArray
Returns a source-shaped array of the running maximum within each piece.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#cummin ⇒ CArray
Returns a source-shaped array of the running minimum within each piece.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#cumprod ⇒ CArray
Returns a source-shaped array of the running product within each piece.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#cumsum ⇒ CArray
Returns a source-shaped array of the running sum within each piece.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#each {|piece| ... } ⇒ Enumerator, self
Yields each piece in turn as a CArray.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#elements ⇒ CArray
Returns the total number of cells in each piece, masked or not.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#map {|piece| ... } ⇒ CArray
Returns a source-shaped array built by applying the block to each piece and scattering the result back into that piece's cells.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#max ⇒ CArray
Returns the largest value in each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#max_addr ⇒ CArray
Returns the flat address in the source of the largest value of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#max_index ⇒ CArray
Returns the position of the largest value within each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#mean ⇒ CArray
Returns the arithmetic mean of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#median ⇒ CArray
Returns the median of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#min ⇒ CArray
Returns the smallest value in each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#min_addr ⇒ CArray
Returns the flat address in the source of the smallest value of each piece -- which source cell holds it, rather than where it sits inside the piece. Use it to read the same cell out of another source-shaped array.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#min_index ⇒ CArray
Returns the position of the smallest value within each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#minmax ⇒ Array<CArray>
Returns the smallest and largest value of each piece, found in one pass.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#percentile(*pers) ⇒ CArray+
Returns the requested percentile(s) of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#prod ⇒ CArray
Returns the product of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#quantile ⇒ Array<CArray>
Returns the five-number summary of each piece,
[min, Q1, median, Q3, max].
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#reduce(init = nil) {|acc, piece| ... } ⇒ Object
Folds the pieces with a block, for a reduction the family does not name.
Without init the first piece seeds the accumulator.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#sort_addr ⇒ CArray
Returns a source-shaped array whose cells, read piece by piece, give the flat source addresses that put that piece in ascending order.
212 213 214 215 216 217 |
# File 'lib/carray/iterator.rb', line 212 [:map, :sort_addr, :cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} does not provide ##{name} (optional)" end end |
#stddev ⇒ CArray
Returns the sample standard deviation (divisor n - 1) of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#stddevp ⇒ CArray
Returns the population standard deviation (divisor n) of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#sum ⇒ CArray
Returns the sum of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#variance ⇒ CArray
Returns the sample variance (divisor n - 1) of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#variancep ⇒ CArray
Returns the population variance (divisor n) of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#wmean(weights) ⇒ CArray
Returns the weighted mean of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |
#wsum(weights) ⇒ CArray
Returns the weighted sum of each piece.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/carray/iterator.rb', line 147 [ :sum, :accumulate, :prod, :mean, :min, :max, # tier 1 :variance, :stddev, :all, :any, :variancep, :stddevp, :minmax, # tier 2 :min_index, :max_index, :min_addr, :max_addr, # position :wsum, :wmean, # weighted :median, :percentile, :quantile, # tier 3 :count, :count_not_masked, :count_masked, :elements, # count family :each, :reduce, # generic iterate ].each do |name| define_method(name) do |*, **, &_blk| raise NotImplementedError, "#{self.class} must implement ##{name}" end end |