Module anchor

Source
Expand description

Anchor-relative trajectory analysis.

Projects trajectories from absolute embedding space (ℝᴰ) into a reference frame defined by K anchor vectors, producing trajectories in ℝᴷ where each dimension is the cosine distance to an anchor.

This enables all existing CVX analytics (velocity, Hurst, changepoints, signatures) to operate on clinically or semantically meaningful coordinates instead of opaque embedding dimensions.

§Example

use cvx_analytics::anchor::{project_to_anchors, AnchorMetric};

let trajectory = vec![
    (1000_i64, vec![1.0_f32, 0.0, 0.0]),
    (2000, vec![0.9, 0.1, 0.0]),
    (3000, vec![0.5, 0.5, 0.0]),
];
let anchors = vec![
    vec![1.0_f32, 0.0, 0.0],  // anchor A
    vec![0.0, 1.0, 0.0],      // anchor B
];

let traj_refs: Vec<(i64, &[f32])> = trajectory.iter().map(|(t, v)| (*t, v.as_slice())).collect();
let anchor_refs: Vec<&[f32]> = anchors.iter().map(|a| a.as_slice()).collect();

let projected = project_to_anchors(&traj_refs, &anchor_refs, AnchorMetric::Cosine);
// projected[0] = (1000, [0.0, 1.0])   -- close to A, far from B
// projected[2] = (3000, [~0.3, ~0.3]) -- equidistant

Structs§

AnchorSummary
Summary statistics for anchor proximity over a trajectory.

Enums§

AnchorMetric
Distance metric for anchor projection.

Functions§

anchor_summary
Compute summary statistics of anchor proximity over a trajectory.
project_to_anchors
Project a trajectory into anchor-relative coordinates.