Quantifying group homogeneity

I'm trying to find a way to quantify the homogeneity of a group.

An example dataset is below, where group D, for example, has 5 members of type1, 1 member of type2, and 1 member of type3. Groups A and B should be considered more pure than group C.

"group" "type1" "type2" "type3" "type4" "type5"
"A"     1       0       0       0       0
"B"     2       1       0       0       0
"C"     1       1       1       1       1
"D"     5       1       1       0       0
"E"     10      1       1       1       1
"F"     1       1       0       0       0


One idea I had was to use something similar to the Gini impurity index. For each group, this would be defined as $\sum_{t=1}^T p_t \left( 1- p_t \right)$, where $p_t$ is the proportion of observations in the group of type $t$.

For group D, for example, this would be $$\frac{5}{7}\left(1-\frac{5}{7}\right) + \frac{1}{7}\left(1-\frac{1}{7}\right) + \frac{1}{7}\left(1-\frac{1}{7}\right) + 0 + 0 = 0.449,$$ and the output would be

"group" "type1" "type2" "type3" "type4" "type5" "total_obs" "impurity"
"A"     1       0       0       0       0       1           0
"B"     2       1       0       0       0       3           0.444
"C"     1       1       1       1       1       5           0.8
"D"     5       1       1       0       0       7           0.449
"E"     10      1       1       1       1       14          0.469
"F"     1       1       0       0       0       2           0.5


Is this an appropriate way to measure group purity/impurity? Or is there another method that would be more appropriate?

• You can also use entropy – Alexey Grigorev Nov 2 '16 at 20:06