3.75

3.8 | 5 ratings Rate this file 27 Downloads (last 30 days) File Size: 1.71 KB File ID: #23077

weighted median

by

 

Function for calculating the weighted median

| Watch this File

File Information
Description

 For n numbers x_1,...,x_n with positive weights w_1,...,w_n,
 (sum of all weights equal to one) the weighted median is defined as
 the element x_k, such that:
           --
           ) w_i <= 1/2
           --
      x_i < x_k
and
           --
          ) w_i <= 1/2
          --
     x_i > x_k

 Input: D ... matrix of observed values
                W ... matrix of weights, W = ( w_ij )
 Output: wMed ... weighted median

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
01 Aug 2014 Song Ming

very useful. And Bart's comments are great too.

03 Oct 2012 petrichor  
20 Oct 2011 Qiao Liyong  
16 Sep 2010 Bart Vorselaars

Useful routine. It can be optimized, though, by using sumVec=cumsum(wSort) -- it gave me a speed-up of more than 300 in a particular case for which I had about 50000 elements.

30 Mar 2009 Fun Flow  
30 Mar 2009 Fun Flow  

Contact us