Main Content

Average or mean value of fixed-point array

computes the
mean value of the real-valued fixed-point array `M`

= mean(`A`

)`A`

along its first
nonsingleton dimension.

computes the mean value of the real-valued fixed-point array `M`

= mean(`A`

,`dim`

)`A`

along
dimension `dim`

. `dim`

must be a positive, real-valued
integer with a power-of-two slope and a bias of 0.

The fixed-point output array, `M`

, has the same `numerictype`

properties as the fixed-point input array,
`A`

.

If the input array, `A`

, has a local `fimath`

, then it is used for intermediate calculations. The output,
`M`

, is always associated with the default
`fimath`

.

When `A`

is an empty fixed-point array (value =
`[]`

), the value of the output array is zero.

The general equation for computing the `mean`

of an array
`A`

, across dimension `dim`

is:

sum(A,dim)/size(A,dim)

Because `size(a,dim)`

is always a positive integer, the algorithm for
computing mean casts `size(A,dim)`

to an unsigned 32-bit `fi`

object with a fraction length of zero (denote this `fi`

object
`'SizeA'`

). The algorithm then computes the mean of `A`

according to the following equation, where `Tx`

represents the
`numerictype`

properties of the fixed-point input array
`A`

:

c = Tx.divide(sum(A,dim), SizeA)