argMax: Arg Max: Extract a subscript corresponding component is a max

Description Usage Arguments Details Value Examples

View source: R/argMax.R

Description

The non-negative valued function of a vector, which returns a subscript whose component is the maximal component of the vector.

If the maximal component is not unique, then the lowest is chosen

Namely, for an arbitrary vector,

argMax(vector) = i

if and only if i is the smallest number such that

vector[i] >= vector[j] for all j.

Usage

1
argMax(numeric_vector, verbose = FALSE)

Arguments

numeric_vector

A vector, each component is a real number (an object of class numeric).

verbose

A logical, if TRUE, then verbose summary is printed in R or R studio console.

Details

This function is very fundamental and so,,, Is there a same function in the package base?

Value

A non-negative integer, indicating a subscript, corresponding component is the maximum component.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     argMax(c(0,0,0,0,0,0,0,0,0,0))
     argMax(c(11,0,0,0,0,0,0,0,0,0))
     argMax(c(0,22,0,0,0,0,0,0,0,0))
     argMax(c(0,0,33,0,0,0,0,0,0,0))
     argMax(c(0,0,0,44,0,0,0,0,0,0))
     argMax(c(0,0,0,0,55,0,0,0,0,0))
     argMax(c(0,0,0,0,0,66,0,0,0,0))
     argMax(c(0,0,0,0,0,0,77,0,0,0))
     argMax(c(0,0,0,0,0,0,0,88,0,0))
     argMax(c(0,0,0,0,0,0,0,0,99,0))

     # If the maximal component is not unique, then the lowest is chosen
     argMax(c(0,0,0,44,0,0,44,0,0,0))


     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(11,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,22,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,33,NaN,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,44,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,55,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,66,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,77,NaN,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,88,NaN,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,99,NaN))
     argMax(c(NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,100))


     argMax(c(NaN,NaN,NaN,22,NaN,55,NaN,NaN,NaN,NaN))
     argMax(c(NaN,44,NaN,11,NaN,NaN,NaN,NaN,NaN,NaN))
     argMax(c(NaN,NaN,33, 33, 33, 33,NaN,NaN,NaN,NaN))

BayesianFROC documentation built on Jan. 23, 2022, 9:06 a.m.