klyn.math.NDArray.mean
method
public mean(ignoreNaN as Boolean = false, where as Boolean[] = null) as Double
Description

Computes the arithmetic mean of all elements.

Parameters
ParameterDescription
ignoreNaNSkip NaNs; otherwise propagate them.
whereOptional flat Boolean mask with one entry per source element.
Returns

Mean value as Double.

Throws
  • ValueException if the array is empty.
Example
import klyn.math

a = NDArray<Int>([1, 2, 3, 4])
print(a.mean())  # 2.5