R/gini.r

Defines functions Gini

Documented in Gini

Gini <- function(x) {
 x <- sort(x)
 n <- length(x)
 w <- rep(1, length=n)/n
 p <- cumsum(w)
 nu <- cumsum(w * x)
 nu <- nu/nu[n]
 sum(nu[-1] * p[-n]) - sum(nu[-n] * p[-1])
}

Try the shipunov package in your browser

Any scripts or data that you put into this service are public.

shipunov documentation built on Feb. 16, 2023, 9:05 p.m.