# Calculate size and density of pre-defined clusters

I am performing semantic similarity on a number of texts. Using PCA, the similarity can be visualized as below Is there a way to quantify the density of each cluster, as well as the overall size? I would like a way to show that TD is more dense than FXSA, as well as smaller in total size.

• These are not clusters, but classes. They are not too similar, either. – Has QUIT--Anony-Mousse May 27 '17 at 15:45

Firstly, there are many distance measures and the distance of the samples to the group mean is a good measure of density of cluster in my opinion. Thus, I would use, for instance, sum of the Mahalanobis distances of each sample which are the variance scaled distances of them to the group mean. You can divide that sum to the number of samples to obtain an average distance. And apparently, for your case, the average distance of TD is expected to be well less than the FXSA's.

There are also Euclidean distance, Manhattan distance and many other. They are all, however, similar except about how they consider the variations. For example in Minkowski metric which is the generalization of the Euclidean and Mahalanobis distance you can alter the impact of a distance by any power you want by changing lambda in the equation below. In this way you can change, for example, the impact of an outlier to your sum of distance measures. As a start, you might try something like calculating the area of the convex hull of each cluster which will give you information about cluster size. Also dividing the number of samples in each cluster by the area of cluster's convex hull you can get the measure of cluster density. Here is some guide for doing so in R: https://chitchatr.wordpress.com/2015/01/23/calculating-the-area-of-a-convex-hull/

The above were just some basic ideas. Hope you'll get more adequate answer.

Since you use PCA there already, the obvious approach would be to:

1. Compute the mean of each cluster

2. Compute the average sum-of-squares deviation in each cluster. $$\frac{1}{|C|} \sum_{x \in C} \sum_i (x_i-\mu_i)^2$$