A simple implementation of the Gini impurity index for classification and regression trees. Not meant to be called directly - included for demonstration purposes.
gini(x, class, splitpoint)
Numeric vector of length n.
Class labels, length n.
Tentative split point.
The Gini impurity index, given a certain split point, a vector of possible splits, and a vector of class labels. Lower values indicate more pure leaves.
R. Wehrens. "Chemometrics with R - Multivariate Data Analysis in the Natural Sciences and Life Sciences". Springer, Heidelberg, 2011.