Skip to contents

Finds a base point p on the manifold for X, using one of the base point methods provided by the manifold (see new_manifold), then validates it with the manifold's cut-locus check (is_valid). For the torus (manifold_torus) the methods are:

  • "auto" (the default): the closed-form, per-coordinate maximal-gap method (auto_base_point_torus), which is not centered on the data, but is guaranteed to avoid the cut locus of X by construction, and is much cheaper to compute.

  • "optimize": numerically minimizes the total torus distance from p to every row of X (a geometric-median-style, data-centered point), via multi-start optim (optimize_base_point_torus). Cut-locus avoidance is checked afterward, not guaranteed by construction.

For hyperbolic space (manifold_hyperbolic), "auto" is the Lorentzian centroid (auto_base_point_hyperbolic) and "optimize" minimizes the total hyperbolic distance (optimize_base_point_hyperbolic); there is no cut locus. For the Grassmann manifold (manifold_grassmann), "auto" is the projection mean (auto_base_point_grassmann) and "optimize" minimizes the total Grassmann distance (optimize_base_point_grassmann).

Usage

choose_base_point(
  X,
  manifold = "torus",
  method = NULL,
  n_start = 10,
  maxit = 200,
  seed = 42
)

Arguments

X

A matrix or data frame of manifold data; rows are samples, columns are coordinates.

manifold

The manifold X lies on: a name accepted by get_manifold ("torus", the default, or "hyperbolic") or a manifold object, such as manifold_grassmann(n, k).

method

Name of one of the manifold's base point methods. If NULL (the default), the manifold's first (default) method is used, i.e. "auto" for the torus.

n_start

Number of random restarts for iterative methods (e.g. "optimize"), used to avoid local minima of the objective. Defaults to 10. Ignored by methods that do not use it.

maxit

Maximum number of optim iterations per restart, for iterative methods. Defaults to 200. Ignored by methods that do not use it.

seed

Integer random seed for iterative methods. Defaults to 42. Ignored by methods that do not use it.

Value

A list with three elements:

p

The chosen base point.

value

The total geodesic distance from p to every row of X, computed with the manifold's dist for every method so they are comparable. Lower means p is more central.

convergence

For iterative methods, the optim convergence code of the best restart (0 indicates successful convergence). NA for non-iterative methods such as "auto".

Stops with an error if the chosen p happens to land on the cut locus of some row of X: for method = "optimize" this suggests a higher n_start, while for the torus method = "auto" it should not happen (up to floating-point tolerance) and indicates degenerate data.

Examples

X <- matrix(stats::runif(20), nrow = 10, ncol = 2)

result_auto <- choose_base_point(X)
result_auto$p
#> [1] 0.7685736 0.9185042

result <- choose_base_point(X, method = "optimize", n_start = 5)
result$p
#> [1] 0.03555437 0.20406689