File:Weighted median.svg
![File:Weighted median.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/Weighted_median.svg/383px-Weighted_median.svg.png?20131203023357)
Original file (SVG file, nominally 383 × 515 pixels, file size: 24 KB)
Captions
Captions
Summary
[edit]DescriptionWeighted median.svg |
English: Two charts showing the difference between an ordinary median and a weighted median. The weight of the element in the list is are indicated by the widths of the boxes and the value by height. The median element is shown in red. |
Date | |
Source |
Own work![]() This W3C-unspecified plot was created with Matplotlib. |
Author | Bscan |
#Python code shown below
#This code is issued under the Creative Commons CC0 "License"
from pylab import *
#Arbitrary values that result in a good illustrative example
data = array([1,3,4,5,8,8.5,9,10.5,11])
weights = array([0.24, 0.60, 0.33,0.28, 0.2, 0.39, 0.2, 0.1, 0.18])
bar_spacing = 0.02 #Distance between adjacent bars
#Non-medians are blue and the median is red
colors = ['b','b','b','b','r','b','b','b','b']
colorsw = ['b','b','b','r','b','b','b','b','b']
#normalize the weights, only needed to get the two plots to line up
weights = weights / sum(weights)
unweights = ones(data.__len__())/data.__len__() #Equal weighting
#The locations start at zero and are spaced by the width
locations = concatenate((array([0]),cumsum(bar_spacing + unweights[:-1])))
locations_w = concatenate((array([0]),cumsum(bar_spacing + weights[:-1])))
figure()
subplot(2,1,1)
bar(locations, data, width=unweights, color = colors)
ylabel('Value')
tick_params(axis='x', which='both',bottom='off',top='off',labelbottom='off')
xlim([-0.02, sum(unweights+0.02)])
grid()
xticks([])
subplot(2,1,2)
bar(locations_w, data, width=weights, color = colorsw)
ylabel('Value')
tick_params(axis='x', which='both',bottom='off',top='off',labelbottom='off')
xlim([-0.02, sum(weights+0.02)])
grid()
xticks([])
Licensing
[edit]![]() ![]() |
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 02:33, 3 December 2013 | ![]() | 383 × 515 (24 KB) | Bscan (talk | contribs) | Minor updates: changed data slightly to make different median more apparent and added grid lines |
02:21, 3 December 2013 | ![]() | 386 × 513 (21 KB) | Bscan (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on id.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 306pt |
---|---|
Height | 412pt |