Array-reducing functions

Revision as of 03:20, 11 December 2015 by Bbecane (talk | contribs)

An array-reducing function operates across a dimension of an array and returns a result that has one dimension less than the number of dimensions of its input array. When applied to an array of n dimensions, a reducing function produces an array that contains n-1 dimensions. Examples include, Sum(x, i), Product(x,i), Max(x, i), Min(x, i), and others described below. The subscript construct x[i = v] and related subscript and slice functions also reduce arrays by a dimension (see Subscript and slice of a subarray).

The function Sum(x, i) illustrates some properties of reducing functions.

Examples

Sum(Car_prices, Car_type) →

Years ▶
2005 2006 2007 2008 2009
59K 62K 66K 71K 76K

Sum(Car_prices, Years) →

Car_type ▶
VW Honda BMW
99K 103K 141K

Sum(Sum(Car_prices, Years), Car_type) → 334K

See Array Function Example Variables for example array variables used here and below.

Tip
The second parameter, i, specifying the dimension over which to sum, is optional. But if the array, x, has more than one dimension, Analytica might not sum over the dimension you expect. For this reason, it is safer always to specify the dimension index explicitly in Sum() or any other array-reducing function.


See Also

Comments


You are not allowed to post comments.