UNPKG

ecclesia

Version:

Framework for political and electoral simulations

32 lines (30 loc) 1.04 kB
/** * The results of a binary vote. * The blank votes are not counted. To calculate a threshold on the whole * number of members, use vote.votesFor / house.nSeats. * To calculate the threshold on the number of duly elected members, use * vote.votesFor / sum(house.members.values()). */ declare class Vote { readonly votesFor: number; readonly votesAgainst: number; constructor(votesFor: number, votesAgainst: number); /** * Returns the reverse of the vote, inverting the for/against ratio. * Simulates a vote on the opposite motion. */ get neg(): Vote; get votesCast(): number; /** * Returns the ratio of votes for over the total number of votes cast. * If there are no votes cast, returns an Infinity. */ get ratio(): number; /** * Returns the votes in order of decreasing ratio. * The ties are ordered by decreasing number of positive votes, * and then by the order they came in. */ static order(votes: Vote[]): Vote[]; } export { Vote };