# ArgStatistics function

There are four methods in the ArgStatistics function: ArgMax, ArgMin, ArgMedian, and Duration.

There are five inputs for this function:

• Methods—Select the statistics method to calculate.
• Undefined class—A constant that will be returned when no definitive output can be calculated.
• Min— The minimum value you set as equal to or greater than the lowest value.
• Max—The maximum value you set as equal to or less than the highest value.
• Index—There are two types of indices in this function: a raster index, and a band index. The input index keeps track of each raster input, where each row with the same input index is the same raster. The band index keeps track of each input band; each band index is unique.

## Methods

### ArgMax

ArgMax stands for the argument of the maximum. In the ArgMax method, all raster bands from every input raster are assigned a 0-based incremental band index, which is first ordered by the input raster index, as shown in the table below, and then by the relative band order within each input raster.

For example, if the first input raster (input index 0) has 2 bands: b11 and b12, and the second input raster (input index 1) has 4 bands: b21, b22, b23, and b24, the band index will look like the following table:

BandInput indexBand index

b11

0

0

b12

0

1

b21

1

2

b22

1

3

b23

1

4

b24

1

5

Then, for each pixel, the ArgMax function returns the Band index for the maximum Pixel value. For example, in the following table, the maximum pixel value is 189, which is stored in Band b21, where the the band index is 2. So, the ArgMax function will return the value 2.

BandBand indexPixel value

b11

0

33

b12

1

54

b21

2

189

b22

3

145

b23

4

34

b24

5

28

### ArgMin

ArgMin is the argument of the minimum, which returns the Band index for which the given pixel attains its minimum value.

For example, in the previous table, the minimum Pixel value is 28, which is stored in Band b24, where the Band index is 5. So, the ArgMin function will return the value 5.

### ArgMedian

The ArgMedian method returns the Band index for which the given pixel attains the median value of values from all bands.

Consider values from all bands as an array. After sorting the array in ascending order, the median is the one value separating the lower half of the array from the higher half. More specifically, if the ascend-sorted array has n values, the median is the ith (0-based) value, where:

``i = ( (n-1) / 2 )``

For example, the previous table is sorted in ascending order by pixel values as shown in the following table. The median is 34, and ArgMedian will return a Band index of 4.

BandBand indexPixel value

b24

5

28

b11

0

33

b23

4

34

b12

1

54

b22

3

145

b21

2

189

### Duration

The Duration method finds the longest consecutive elements in the array, where each element has a value greater than or equal to Min and less than or equal to Max, and then returns its length. The Duration method needs the Min and Max input values.

For example, in the previous table, the longest consecutive elements given are Min=34 and Max=189 is [34, 54, 145, 189], so the duration is 4.

## Undefined class

The undefined class is a constant input that will be returned when no definitive maximum, minimum, or median can be attained. The most common scenario is when the maximum or minimum value occurs more than once among values from all bands. The default value for the undefined constant is 100.

The undefined class is only applicable when the method is ArgMax, ArgMin, or ArgMedian.

## Min and Max

Min and Max are the values you set to find the Duration method. The Min value that you set is the lowest value equal to or greater than the beginning of the duration. The Max value that you set is the highest value equal to or less than the end of the duration.

The Min and Max inputs are only applicable when the method is Duration.

## Index

There are two types of indices in this function: a raster index, and a band index. The input index keeps track of each raster input, where each row with the same input index is the same raster. Since a raster can have more than one band, there may be multiple rows with the same raster index. The band index keeps track of each input band. Each band index is unique and cannot have duplicates.