Last active
February 13, 2022 14:39
-
-
Save JosepER/df29af9b947517314052cea412e7d403 to your computer and use it in GitHub Desktop.
Weighted inequality indicators
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
##### Atkinson index ##### | |
""" | |
atkinson(v, w, ϵ) | |
Computes the weighted Atkinson index given an inequality adversion parameter ϵ. | |
""" | |
function wtd_atkinson(v::Array{<:Real,1}, w::Array{<:Real,1}, ϵ::Real) ::Float64 | |
v = v/Statistics.mean(v) | |
w = w/sum(w) | |
if ϵ == 1 | |
w = w[v .!= 0] | |
v = v[v .!= 0] | |
return 1 - (prod(exp.(w.*log.(v)))/sum(v .* w/sum(w)) ) | |
elseif ϵ < 1 | |
return 1-(sum(((v/sum(v.*w/sum(w))).^(1-ϵ)).*w/sum(w))).^(1/(1-ϵ)) | |
else | |
w = w[v .!= 0] | |
v = v[v .!= 0] | |
return 1-(sum(((v/sum(v.*w/sum(w))).^(1-ϵ)).*w/sum(w))).^(1/(1-ϵ)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment