Created
March 30, 2022 19:33
-
-
Save JosepER/0e060deb81cec689e7a93010f9f953f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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