Chooses the specified number of initial centers from the given data matrix, for clustering algorithms such as k-means.

Namespace:  CenterSpace.NMath.Stats
Assembly:  NMathStats (in NMathStats.dll) Version: 3.4.0.0

Syntax

C#
public static int[] InitialCenters(
	DoubleMatrix data,
	int k
)
Visual Basic (Declaration)
Public Shared Function InitialCenters ( _
	data As DoubleMatrix, _
	k As Integer _
) As Integer()
Visual C++
public:
static array<int>^ InitialCenters(
	DoubleMatrix^ data, 
	int k
)

Parameters

data
Type: CenterSpace.NMath.Core..::.DoubleMatrix
A matrix of data. Each row in the matrix represents an object to be clustered.
k
Type: System..::.Int32
The number of initial cluster centers.

Return Value

An array of row indices.

Remarks

Uses the following algorithm: If the distance between row r and its closest center is greater than the distance between the two closest centers (m, n), then r replaces m or n, whichever is closest to r. Otherwise, if the distance between row r and its closest center (q) is greater than the distance between q and its closest center, then row r replaces q. (Similar to SPSS QuickCluster function.)

Exceptions

ExceptionCondition
CenterSpace.NMath.Core..::.InvalidArgumentException Thrown if the number of cluster centers is less than one or greater than the number of data points (data.Rows).

See Also