Intrinsic dimension#

Dimension estimators summarize local or multiscale geometry without producing an embedding. Correlation Dimension fits correlation-integral scaling; TwoNN, Levina–Bickel MLE, and MiND-ML use nearest-neighbor laws. Tight Local Estimation uses distances from moving centers in each neighborhood. U-Statistic Dimension uses convergence rates and DANCo combines norm and angle concentration [Amsaleg et al., 2022, Ceruti et al., 2014, Facco et al., 2017, Grassberger and Procaccia, 1983, Hein and Audibert, 2005, Levina and Bickel, 2004, Lombardi et al., 2011].

Correlation-integral methods identify a scaling regime where

\[C(r) \propto r^d.\]
import numpy as np

from believe14.estimation import (
    DANCo,
    CorrelationDimension,
    LevinaBickelMLE,
    MiNDML,
    TightLocalEstimator,
    TwoNN,
    UStatisticDimension,
)

rng = np.random.default_rng(14)
flat = rng.uniform(-1.0, 1.0, size=(120, 2))
X = np.column_stack(
    (flat, flat[:, 0] + 0.3 * flat[:, 1], np.zeros((120, 2)))
)

models = [
    CorrelationDimension(),
    TwoNN(),
    TightLocalEstimator(n_neighbors=12),
    LevinaBickelMLE(k_min=5, k_max=10),
    UStatisticDimension(max_dimension=3, random_state=14),
    MiNDML(n_neighbors=6, max_dimension=3),
    DANCo(n_neighbors=6, max_dimension=3, random_state=14),
]

for model in models:
    model.fit(X)
    assert np.isfinite(model.dimension_)
    assert model.diagnostics_.converged
    print(f"{type(model).__name__:24s} dimension={model.dimension_:.3f}")
CorrelationDimension     dimension=1.722
TwoNN                    dimension=1.721
TightLocalEstimator      dimension=2.166
LevinaBickelMLE          dimension=1.821
UStatisticDimension      dimension=2.000
MiNDML                   dimension=1.805
DANCo                    dimension=2.000

The continuous estimates need not be integers; U-Statistic Dimension and DANCo select from discrete candidates. Estimates are meaningful only inside each method’s sample-size, neighbor, tie, and support assumptions. fit stores dimension_, optional local_dimensions_, and diagnostics_; these classes do not invent predict, score, or transform.

DANCo boundary

DANCo’s angular statistic is degenerate for intrinsically one-dimensional or collinear data. DANCo rejects that regime explicitly and searches candidate dimensions starting at two.

Dimension across observations and scales#

Rows of local_dimensions_by_k_ correspond to the fitted observations. Columns follow k_values_. Levina–Bickel reports the entire requested range and Tight Local Estimation reports one column for its chosen neighborhood size. On a mixture of manifolds, compare observations within each region. A global mean can fall between the dimensions of the two regions. A neighborhood crossing their boundary can mix their geometries.

from believe14.neighbors import build_neighbor_graph

neighbors = build_neighbor_graph(X, n_neighbors=15)
local = LevinaBickelMLE(k_min=5, k_max=15).fit(X, neighbors=neighbors)
assert local.local_dimensions_by_k_.shape == (len(X), 11)
print(local.k_values_)
print(np.median(local.local_dimensions_by_k_, axis=0).round(2))
[ 5  6  7  8  9 10 11 12 13 14 15]
[1.52 1.52 1.64 1.67 1.73 1.75 1.75 1.76 1.72 1.71 1.73]

TwoNN needs two neighbors in the graph. Levina–Bickel needs k_max, Tight Local Estimation needs n_neighbors, and MiND-ML and DANCo need n_neighbors + 1. DANCo computes separate neighborhoods for its simulated calibration samples.

See Tight Local Estimation, Correlation Dimension, TwoNN, Levina–Bickel MLE, U-Statistic Dimension, MiND-ML, and DANCo.