pub fn dim_select(sv: &[f64]) -> Result<usize>Expand description
Dimensionality selection by profile likelihood (igraph_dim_select).
Given the (decreasingly) ordered “importance” values of the dimensions —
typically the singular values of an adjacency spectral embedding — it
models them as a mixture of two Gaussians with different means and equal
variance, and returns the number d of leading values that maximizes the
likelihood when the first d values are assigned to one component and
the rest to the other. Also usable for any “where is the gap” problem.
Time complexity: O(n).
Binds igraph_dim_select.
When no profile likelihood is a finite number — e.g. when all the values
are equal, so that every one of them is NaN — igraph 1.0.0 and 1.0.1
leave the result unset; this wrapper then returns sv.len() (all values
in one group).
§Errors
If sv is empty or contains NaN or infinite values.
§Examples
use igraph::linalg::dim_select;
assert_eq!(dim_select(&[10.0, 9.8, 9.9, 1.0, 1.1, 0.9, 1.0]).unwrap(), 3);
assert_eq!(dim_select(&[5.0]).unwrap(), 1);
// No gap at all: everything is one group.
assert_eq!(dim_select(&[2.0, 2.0, 2.0]).unwrap(), 3);