dim_select#
- graph_tool.spectral.dim_select(x)[git][source]#
Select the number of dimensions from a sequence of eigenvalues or singular values, with the profile likelihood method of Zhu and Ghodsi.
- Parameters:
- xiterable of
float Values (e.g. singular values), which are sorted in non-increasing order.
- xiterable of
- Returns:
- d
int The number of dimensions, i.e. the number of values in the first group.
- d
See also
spectral_embeddingSpectral embedding of the vertices
Notes
The sorted values \(x_1\ge\dots\ge x_n\) are split in two groups, \(\{x_1,\dots,x_d\}\) and \(\{x_{d+1},\dots,x_n\}\), modelled as independent samples from two normal distributions with different means \(\mu_1,\mu_2\) and a common variance \(\sigma^2\) [zhu-automatic-2006]. The value of \(d\) returned maximizes the profile log-likelihood
\[\ell(d) = -\frac{n}{2}\ln\hat\sigma^2 - \frac{1}{2\hat\sigma^2} \left[\sum_{i\le d}(x_i - \hat\mu_1)^2 + \sum_{i>d}(x_i-\hat\mu_2)^2\right],\]where \(\hat\mu_1\) and \(\hat\mu_2\) are the means of the two groups and \(\hat\sigma^2\) is the pooled variance, with denominator \(n-2\). The case \(d=n\) (a single group, with the sample variance) is also considered, and splits with zero variance are skipped. It runs in time \(O(n\log n)\).
References
[zhu-automatic-2006]Mu Zhu and Ali Ghodsi, “Automatic dimensionality selection from the scree plot via the use of profile likelihood”, Computational Statistics & Data Analysis 51, 918-930 (2006), DOI: 10.1016/j.csda.2005.09.010 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["football"] >>> A = gt.adjacency(g).toarray() >>> x = np.abs(np.linalg.eigvalsh(A)) >>> print(gt.dim_select(x)) 11