Skip to contents

The objective is convex but not differentiable at the data points, and that is the difficulty: the update divides by the distance to each point, so landing exactly on one blows up. A point whose distance underflows is skipped. tol is accepted and ignored – a fixed iteration count is what makes the arms agree.

Usage

Weisz(X, tol = NULL, max_iter = 200)

Arguments

X

Points.

tol

Ignored; interface compatibility only.

max_iter

Iterations.

Value

List with estimate, cost, n, d.

Details

Formula: mu = (sum w_i x_i)/(sum w_i), w_i = 1/||x_i - mu||.

References

Weiszfeld, E. (1937). Tohoku Math J 43:355-386.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Weisz(V)
#> $estimate
#> [1] 4.5
#> 
#> $cost
#> [1] 16
#> 
#> $n
#> [1] 8
#> 
#> $d
#> [1] 1
#> 
#> $method
#> [1] "Weiszfeld iteration, geometric median"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"