View source: R/total_within_cluster_variance.R

total_within_cluster_variance | R Documentation |

Calculates *Total Within Cluster Variance(TWCV)* of
3D points. This function is normally only used
indirectly through 'validate_get_twcv'.

```
total_within_cluster_variance(point_matrix, cluster_vector)
```

`point_matrix` |
An n-by-3 numerical matrix where each row corresponds to a single point in 3D space. |

`cluster_vector` |
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).

`centroid_3d_sq_dist`

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.