Skip to main content

dim_select

Function dim_select 

Source
pub fn dim_select(sv: &[f64]) -> IgraphResult<usize>
Expand description

Select the number of significant values by profile likelihood.

The slice sv holds the ordered values (e.g. singular values, largest first). The returned d (a count in 1..=sv.len()) is the split that maximises the two-component equal-variance Gaussian-mixture profile log-likelihood. The values are used in the given order; this routine does not sort them.

§Errors

§Examples

use rust_igraph::dim_select;

// A clean two-level ramp: the elbow sits at the midpoint.
let sv: Vec<f64> = (1..=100).map(|i| i as f64).collect();
assert_eq!(dim_select(&sv).unwrap(), 50);

// A single value is trivially one-dimensional.
assert_eq!(dim_select(&[3.5]).unwrap(), 1);