Expand description
Hierarchical Risk Parity (HRP) — pure math functions.
Three-phase algorithm:
- Compute correlation → distance matrix → agglomerative clustering (average linkage)
- Build dendrogram (binary tree of clusters)
- Recursive bisection following dendrogram with inverse-variance weighting
All functions are pure math: &[f64] in, f64 out. No domain types,
no I/O. The adapter wraps domain types (e.g. LegReturns) into raw slices
before calling these functions.
Enums§
- Cluster
Node - Binary tree node representing hierarchical clustering.
Constants§
- MIN_
OBSERVATIONS - Minimum number of return observations required to compute a meaningful correlation matrix.
Functions§
- build_
dendrogram - Build a dendrogram using agglomerative clustering with weighted average linkage.
- cluster_
variance - Compute average variance for a cluster (sum of leaf variances / leaf count).
- cluster_
variance_ sum - correlation_
matrix - Compute the Pearson correlation matrix from return series.
- decimal_
from_ f64 - Convert f64 to Decimal with 6 decimal places precision.
- distance_
matrix - Convert correlation to distance: d(i,j) = sqrt((1 - corr(i,j)) / 2)
- find_
closest_ pair - mean
- recursive_
bisect - Walk the dendrogram tree, splitting weight between left and right subtrees using inverse-variance allocation at each branch.
- variance