gini.proc <- function(pvect){
#
# Procedure to compute the normalized Gini heterogeneity measure
#
# Note: the input variable pvect is assumed to be a normalized
# probability vector that sums to 1 and is of length M.
# Missing values are not allowed, but components of pvector
# are allowed to be zero.
#
M <- length(pvect)
if (M == 1){
IGini <- 0
}
else{
prefactor <- (M+1)/(M-1)
wts <- (2*seq(1,M,1))/(M+1) - 1
psort <- sort(pvect)
rawsum <- sum(wts*psort)
IGini <- prefactor * rawsum
#
}
round(IGini,digits=6)
#
}