# ArrayReduce

ArrayReduce[f,array,n]

reduces dimension n of array by applying f.

ArrayReduce[f,array,n1;;n2]

reduces dimensions n1 through n2.

ArrayReduce[f,array,{n1,n2,}]

reduces dimensions n1, n2, etc.

ArrayReduce[f,array,{{n11,n12,},{n21,n22,},}]

applies f to arrays formed by combining all dimensions nij to make each dimension i.

# Details • Array reduction, also called array aggregation, is used to compute functions such as Mean, Total or StandardDeviation along specific dimensions of an array.
• In ArrayReduce[f,array,n], f is applied to every vector along the n dimension of array. It can be seen as a transposition where dimension n becomes the last dimension, followed by the application of f on the lowest-level vectors:
• • If array has dimensions {d1,d2,}, and if the function is transforming a vector into a scalar, the results is an array that has the same dimensions as array except for dn, which is dropped.
• In ArrayReduce[f,array,n1;;n2] and ArrayReduce[f,array,{n1,n2,}], f is applied to every vector formed by combining and flattening the specified dimensions.
• In ArrayReduce[f,array,{{n11,n12,},{n21,n22,},}], f is applied to arrays of arbitrary ranks instead of vectors only.
• ArrayReduce[f,array,{n1,n2,}] is equivalent to ArrayReduce[f,array,{{n1,n2,}}].

# Examples

## Basic Examples(3)

Compute the mean of every row of a matrix:

Compute the mean of every column of a matrix:

Define an array of rank 3:

Compute the standard deviation over the second dimension:

The resulting array is of rank 2, and the second axis has been removed:

Visualize the input and output arrays:

Define an array of rank 5:

Reduce the dimensions of the array by computing the total over dimensions 2 and 4: