klyn.math.NDArray.mean
method

    public mean(axis as Int) as NDArray<Double>:

Description

Computes the arithmetic mean along one axis.

Parameters

Parameter | Description
--- | ---
`axis` | `0` for columns, `1` for rows on 2D arrays.

Returns

A 1D `NDArray<Double>` containing axis means.

Throws

- IndexException if the axis does not exist.
- ValueException if the array is empty or has unsupported dimensions.

Example

    import klyn.math

    a = NDArray<Int>.fromList([[1, 2], [3, 4]])
    print(a.mean(0))  # [2.0, 3.0]
    print(a.mean(1))  # [1.5, 3.5]