[EM] Mean Weighted Political Distance, Part 2
Dan Bishop
danbishop04 at gmail.com
Thu Apr 2 22:49:48 PDT 2009
For a more efficient method of computing MWPD on a uniform political
spectrum, observe that over any interval in which all voters have the
same order of preference (i.e., between two points that are midpoints
between candidates), the WPD is the sum of absolute value functions
centered at each candidate. If we also include the candidate positions
themselves as boundary points, then the WPD is a straight line segment
over each interval, so integrating it requires simply finding the area
of a trapezoid. Thus, the MWPD can be computed as:
def linear_mwpd(candidates):
"""
Mean Weighted Politcal Distance on a uniform linear spectrum.
candidates = coordinates of the candidates (between 0 and 1)
"""
critical_points = set([0, 1])
for cand1 in candidates:
for cand2 in candidates:
critical_points.add((cand1 + cand2) / 2)
sorted_cp = sorted(critical_points)
result = 0
for low, high in zip(sorted_cp[:-1], sorted_cp[1:]):
mid = (low + high) / 2
width = high - low
distances = sorted(abs(mid - candidate) for candidate in candidates)
for index, dist in enumerate(distances):
result += dist / (index + 1) * width
return result
The results of my simulations to find the optimal candidate set are:
{0.5} --> 0.25
{0.37499999988319355, 0.62500000011680656} --> 0.34375
{0.30952378373473316, 0.5, 0.6904762162652669} --> 0.39484126984127094
{0.2676758158861115, 0.42676788016347578, 0.57323211983652422,
0.73232418411388855} --> 0.42760942761107096
{0.23806066570959628, 0.37686611982478441, 0.5, 0.62313388017521554,
0.76193933429040372} --> 0.45066542288719574
{0.21573576423391647, 0.34004090761866429, 0.44800610652086625,
0.55199389347913375, 0.65995909238133565, 0.78426423576608362} -->
0.46789281516205333
Or, as fractions:
{1/2} --> 1/4
{3/8, 5/8} --> 11/32
{13/42, 1/2, 29/42} --> 199/504
{53/198, 169/396, 227/396, 145/198} --> 127/297
{319/1340, 101/268, 1/2, 167/268, 1021/1340} --> 72467/160800
{85/394, 169/497, 517/1154, 637/1154, 328/497, 309/394} -->
716777674392488813/1531927080643703520
More information about the Election-Methods
mailing list