Learn R Programming

LPCM (version 0.47-4)

ms.rep: Mean shift procedures.

Description

Functions for mean shift, iterative mean shift, and inverse mean shift.

Usage

meanshift(X, x, h)
ms.rep(X, x, h, thresh= 0.0001, iter=200)
ms.rep.min(X, x, h, thresh=0.000001, iter=200, adjust.convergence=FALSE, verbose=TRUE)

Value

The function meanshift delivers a single (vector-valued) value.

The functions ms.rep and ms.rep.min produce a list with the following items:

Meanshift.points

(called M for ms.rep.min); the trajectory of points found while proceeding from the starting value x to the mode (or antimode, respectively)

Threshold.values

These give the iteration-wise values of the relative length of the mean shift step (explained in the Note section) which are then compared to thresh.

start

The starting value.

final

The mode or antimode, respectively.

Arguments

X

data matrix or vector.

x

point from which we wish to shift to the local mean.

h

scalar or vector-valued bandwidth; see also description in ms.

thresh, iter

mean shift iterations are stopped when the mean shift length (relative to the distance of of x to the overall mean; see Note section) falls below thresh, or after iter iterations (whatever event happens first).

adjust.convergence

Unimplemented. See also Notes section below.

verbose

Allows or suppresses text output messages.

Author

J. Einbeck. See LPCM-package for further acknowledgements.

Details

The function meanshift computes a single mean shift iteration, and ms.rep computes an iterative series of mean shift iterations. Both of these functions are rarely used on their own, but are typically called by the overarching function ms.

The function ms.rep.min is an experimental function for the computation of antimodes based on an inverse version of the mean shift procedure. This function has only be tested for one-dimensional data (Ameijeiras-Alonso and Einbeck, 202x). It may or may not produce a result for higher data dimensions, but the methodology has not been properly investigated for this case, i.e. any result obtained could be something different to an antimode.

References

Ameijeiras-Alonso, J. and Einbeck, J. (202x). A fresh look at mean-shift based modal clustering. Under submission.

See Also

ms

Examples

Run this code
data(stamps, package="multimode")
h0 <- 0.005
hist(stamps, breaks=20)
# Take arbitrary starting value x=0.08, sitting between a mode and antimode
mode <- ms.rep(stamps, 0.08,h0)$final
antimode <- ms.rep.min(stamps, 0.08,h0, verbose=FALSE)$final
segments(mode, 0, mode, 100, col=2, lwd=3)
segments(antimode, 0, antimode,100, col=3, lwd=3)

Run the code above in your browser using DataLab