| which.min.fair {spatstat.utils} | R Documentation |
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.
which.min.fair(x) which.max.fair(x)
x |
numeric, logical, integer or double vector. |
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.
A single integer (or integer(0) if all entries of x are
NA or NaN).
Adrian Baddeley Adrian.Baddeley@curtin.edu.au
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))