3.5

3.5 | 3 ratings Rate this file 14 Downloads (last 30 days) File Size: 1.71 KB File ID: #23077

weighted median

by Sven Haase

 

23 Feb 2009

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
30 Mar 2009 Fun Flow  
30 Mar 2009 Fun Flow  
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.

20 Oct 2011 Qiao Liyong  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
median Sven Haase 23 Feb 2009 11:59:41
weighted median Sven Haase 23 Feb 2009 11:59:41
statistics Sven Haase 23 Feb 2009 11:59:41
smoothing Sven Haase 23 Feb 2009 11:59:41
median filter Sven Haase 23 Feb 2009 11:59:41
weighted median Durga Sampathkumar 03 Jun 2010 11:39:33
median filter usman khan 05 Oct 2010 06:30:28
median filter Ari 29 Oct 2010 04:07:14

Contact us at files@mathworks.com