cr_argmax: Apply an arg max choice rule

Description Usage Arguments Details Value References Examples

View source: R/cr_argmax.R

Description

Apply an arg max choice rule

Usage

1
cr_argmax(x, tol = sqrt(.Machine$double.eps))

Arguments

x

A numeric vector or matrix with probabilistic predictions for actions. If x is a vector, binary actions are assumed. If x is a matrix, column 1 holds predictions for action 1, column 2 for action 2, etc.

tol

A small number to avoid numeric tolerance problems in finding the maximum in x

Details

The returned values are typically 1 for the row maximum or 0, except if n actions have the maximum probability the result is 1/n, correcting ties by equal choice probability. If the iput is a vector it is silently coerced to a two-column matrix.

Value

A numeric vector or matrix (depending on the input) of indicators of the maximum.

References

Sutton, R. S., & Barto, A. G. (1998). Reinforcement learning: An introduction. Cambridge, MA: MIT Press

Examples

1
2
3
# No examples
cr_argmax(c(0.1, 0.5, 0.8))                     # Returns a vector
cr_argmax(cbind(c(0.1, 0.9), c(0.5, 0.4)))      # Returns a matrix

JanaJarecki/cognitiveutils documentation built on Sept. 9, 2020, 9:11 a.m.