Skip to content

Instantly share code, notes, and snippets.

@ge0ffrey
Created January 3, 2017 15:54
Show Gist options
  • Save ge0ffrey/458dd9f28685b3197cda66c5f7769eb9 to your computer and use it in GitHub Desktop.
Save ge0ffrey/458dd9f28685b3197cda66c5f7769eb9 to your computer and use it in GitHub Desktop.
rule "Fairness standard deviation"
when
accumulate (
$c : candidate
accumulate (
$f : FederalState ( winningCandidate == $c );
$candidateSum : sum( $f.getElectoralVotes() )
);
$variance : sum($candidateSum * $candidateSum)
)
then
// Square root of variance is standard deviation
scoreHolder.addSoftConstraintMatch(kcontext, Math.sqrt($variance));
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment