Reciprocal Score Voting: Difference between revisions

mathematica code
No edit summary
(mathematica code)
Line 22:
 
The <math>\min(\cdot, 1)</math> condition above is required so that support is never amplified by asymmetry. This is also necessary so that a smaller faction cannot parasite on the support of a larger faction, which will never rate the smaller faction above its own. A smaller faction artificially rating a larger faction too highly will only receive exactly as much support as the larger faction is willing to give it.
 
== Implementation ==
 
The following Mathematica code takes a list of score ballots and returns the Reciprocal Score Vote mean score.
 
<syntaxhighlight lang="Mathematica" line='line'>
RSV[ballots_] := Module[{i, factionmask, factionratings, nc, nv},
{nv, nc} = Dimensions[ballots];
factionmask = KroneckerDelta /@ (# - Max[#]) & /@ ballots;
factionratings = Mean /@ Table[
Select[ballots, (KroneckerDelta /@ (# - Max[#]))[[i]] == 1 &],
{i, 1, nc}
];
Mean@Table[
fif =
Mean@(Transpose@factionratings)[[Flatten@
Position[factionmask[[i]], 1]]];(* i\[Rule]\[Phi] *)
ffi =
Mean@factionratings[[Flatten@
Position[factionmask[[i]], 1]]];(* \[Phi]\[Rule]i *)
ballots[[i]] (Min[1, #[[1]]/If[#[[2]] == 0, 1, #[[2]]]] & /@
Thread[{fif, ffi}]),
{i, 1, nv}
]
];
</syntaxhighlight>
 
[[Category:Cardinal voting methods]]
295

edits