Calculates Total Within Cluster Variance(TWCV) of 3D points. This function is normally only used indirectly through `validate_get_twcv`.
An n-by-3 numerical matrix where each row corresponds to a single point in 3D space.
A numerical vector of cluster assignments, of length n (ie one assignment per point).
A one-element numeric vector holding calculated variance
TWCV is a synr-specific term for a measure that aims to describe spread of points in 3D space while taking into account that points belong to distinct clusters. TWCV is calculated in a multi-step process:
Each cluster's centroid is calculated.
All points' squared distances to their corresponding centroids are calculated.
The point-to-centroid squared distances are summed up.
The sum of squared distances is divided by the total number of points, minus the number of clusters (to account for decreased degrees of freedom).