Method: NMatrix#mean

Defined in:
lib/nmatrix/math.rb

- (Object) mean(dimen = 0)

call-seq:

mean() -> NMatrix
mean(dimen) -> NMatrix

Calculates the mean along the specified dimension.

This will force integer types to float64 dtype.

See Also:



276
277
278
279
280
281
282
283
284
# File 'lib/nmatrix/math.rb', line 276

def mean(dimen=0)
  reduce_dtype = nil
  if integer_dtype? then
    reduce_dtype = :float64
  end
  inject_rank(dimen, 0.0, reduce_dtype) do |mean, sub_mat|
    mean + sub_mat/shape[dimen]
  end
end

Comments