R/which_max_random.R

# this is borrowed from nnet::which.is.max
which.max.random <- function (x)
{
  mx <- x == max(x, na.rm = TRUE)
  mx[is.na(mx)] <- FALSE
  y <- seq_along(x)[mx]
  if (length(y) > 1L)
    sample(y, 1L)
  else
    y
}

Try the pomdp package in your browser

Any scripts or data that you put into this service are public.

pomdp documentation built on May 29, 2024, 2:04 a.m.