Learn R Programming

speccalt (version 0.1.1)

bartlett: bartlett

Description

Adaptation of the Bartlett statistical test for equal variances, to a procedure of detection of the optimal number of clusters, in the context of spectral clustering.

Usage

bartlett(eigvals, thres=0.95, maxk=20)

Arguments

eigvals
A vector of eigenvalues, as returned by the eigendecomposition of the normalized Laplacian (see examples), i.e. in decreasing order.
thres
1 - alpha significance threshold, defaults to 95
maxk
upper bound to the returned value.

Value

The computed optimal number of clusters.

Examples

Run this code
	# normalized Laplacian computation
	kern <- local.rbfdot(synth1)
	nelts <- dim(kern)[1]
	diag(kern) <- 0
	deg <- sapply(1:nelts, function(i) {
		return(sum(kern[i,]))
	})
	deg <- diag(deg)
	L <- diag(nelts) - solve(deg) 
	eig <- eigen(L)

	optK <- bartlett(eig$values)$k

Run the code above in your browser using DataLab