which.min.fair {spatstat.utils}R Documentation

Where is the Minimum or Maximum

Description

Determines the index of the minimum or maximum of a vector. If there are multiple entries which achieve the minimum or maximum, one of the indices is selected at random.

Usage

which.min.fair(x)
which.max.fair(x)

Arguments

x

numeric, logical, integer or double vector.

Details

These functions are alternatives to the standard R functions which.min and which.max.

The standard functions which.min and which.max find the index of the first entry in the vector x which achieves the minimum or maximum value. This can cause a bias in some simulation experiments.

The functions which.min.fair and which.max.fair identify all entries of the vector x which achieve the minimum or maximum respectively, and select one of them at random.

Value

A single integer (or integer(0) if all entries of x are NA or NaN).

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

See Also

which.min

Examples

  z <- c(20, 40, 20, 10, 40, 20, 10, 20, 40)
  replicate(5, which.max(z))
  replicate(5, which.max.fair(z))
  replicate(5, which.min.fair(z))

[Package spatstat.utils version 3.0-5 Index]