Skip to content

Instantly share code, notes, and snippets.

@JosepER
Created March 30, 2022 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosepER/0e060deb81cec689e7a93010f9f953f9 to your computer and use it in GitHub Desktop.
Save JosepER/0e060deb81cec689e7a93010f9f953f9 to your computer and use it in GitHub Desktop.
v <- c(8,5,1,3,5,6,7,6,3) # income
w <- seq(0.1, 0.9, 0.1) # weights
w <- w[order(v)]
v <- sort(v)
# compute πₖ
y <- unique(v)
pi_k <- purrr::map_dbl(split(w, v), sum)/sum(w)
# compute Fₖ
# F_k <- rep(0, length(pi_k))
#
# for(i in 2:length(F_k)){
#
# F_k[i] <- F_k[i-1] + 0.5 * pi_k[i-1]
#
# }
F_k <- c(cumsum(0.5 * pi_k))
mean(F_k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment