Using the Weiszfeld algorithm an iterative method to compute the geometric median of a set of points in Euclidean space. In general, measures of central tendency minimize the sum of the Euclidean distance from the center to each point in the set. We try to come up with an estimate of this center by first using our best guess and then approximating it by calculating the distance from each point to a newly chosen point in the set and updating the center if the distance is smaller than that calculated using our best, initial guess.
Details
If your sample is a 1D set of points use median
or grouped.median
instead.
The geom.median
function is used for samples of points in +2D space.
Examples
d <- rlnorm(60,1,1.4)
geom.median(d,iters = 100)
#> [1] 2.7419
x <- matrix(rlnorm(60,1,1.4),ncol = 4)
mapply(geom.median, as.data.frame(x))
#> V1 V2 V3 V4
#> 0.7132444 1.2380142 2.7550766 2.5423200