circle_bundles.RP1UnitVectorMetric

class circle_bundles.RP1UnitVectorMetric(name='RP1_unitvec', base_name='RP^1', base_name_latex='\\mathbb{RP}^1')[source]

Bases: object

Geodesic distance on \(\mathbb{RP}^1\) using unit vectors in \(\mathbb{R}^2\).

Points are represented by unit vectors in \(\mathbb{R}^2\), but with the antipodal identification:

\[p \sim -p.\]

Therefore the distance between classes [p] and [q] is:

\[d([p],[q]) = \arccos(|\langle p, q \rangle|).\]

This is the correct metric when the base variable represents unoriented directions (i.e. an axis rather than an arrow).

Parameters:
  • name (str)

  • base_name (str)

  • base_name_latex (str)

name

Metric identifier (default "RP1_unitvec").

Type:

str

base_name

Short name of the base space for plots/UI.

Type:

str

base_name_latex

LaTeX symbol used in summaries and tables.

Type:

str

Notes

  • This implementation is robust to small deviations from unit norm: it normalizes input rows internally.

  • Distances are in radians in the range [0, π/2] for true unit inputs (because of antipodal identification).

__init__(name='RP1_unitvec', base_name='RP^1', base_name_latex='\\mathbb{RP}^1')
Parameters:
  • name (str)

  • base_name (str)

  • base_name_latex (str)

Return type:

None

Methods

__init__([name, base_name, base_name_latex])

pairwise(X[, Y])

Compute projective geodesic distances between unit-vector samples.

Attributes

base_name

base_name_latex

name

pairwise(X, Y=None)[source]

Compute projective geodesic distances between unit-vector samples.

Parameters:
  • X (ndarray) – Array of shape (n, 2) representing vectors in \(\mathbb{R}^2\). Rows should be (approximately) unit length.

  • Y (ndarray | None) – Optional array of shape (m, 2). If omitted, uses X.

Returns:

Distance matrix of shape (n, m) with entries in radians.

Return type:

D

Raises:

ValueError – If X or Y does not have shape (*, 2) after reshaping 1D inputs.