reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

shareoftopXpercent.m (463B)


      1 function xprc=shareoftopXpercent(x,prctile);
      2 
      3 % shareoftopXpercent.m   function [xprc,indx]=shareoftopXpercent(x,prctile);
      4 %
      5 % What share of sum(x) is accounted for by the top prctile of the data?
      6 % Useful for inequality: e.g. what share of income goes to the top 1% or 10%?
      7 %
      8 %    shareoftopXpercent(income,.01)
      9 %    shareoftopXpercent(income,.10)
     10 
     11 
     12 [N,K]=size(x);
     13 i=round(prctile*N);
     14 totalx=sum(x);
     15 xsort=flipud(sort(x));
     16 xprc=sum(xsort(1:i))/totalx;
     17 
     18 %keyboard