usnistgov / CastVoteRecords

Common data format specification for cast vote records
https://pages.nist.gov/CastVoteRecords
Other
20 stars 2 forks source link

Support for fractional votes #19

Closed JDziurlaj closed 5 years ago

JDziurlaj commented 5 years ago

Support the expression of fractional votes, either as decimal fractions (e.g. 0.25) or as a rational number (e.g. 1/4)

Rationale

This change is suggested to improve support for voting methods that produce fractional values, e.g. RCV and Cumulative voting.

The attributes CVRContestSelection::TotalNumberVotes and SelectionPosition::NumberVotes are typed as Integer, which makes expressing fractional values impossible.

Approach

The approach is driven by the following constraints:

Thus, the existing attributes will remain unchanged. Instead this proposal adds two attributes, CVRContestSelection::TotalFractionalVotes and SelectionPosition::FractionalVotes as a String type. When represented as XML or JSON, a pattern constraint will be added, as the following regular expression:

([0-9]+/[1-9]+[0-9]*)|(\.[0-9]+)

When a decimal numerals are used, they must begin with a decimal separator (e.g. a decimal point)

{
    "FractionalVotes": ".25" 
}

This is to make conversion easier, for example 1/4 will cast to 0.25 in a programming language such as Python or JavaScript.

{
    "FractionalVotes": "1/4" 
}

I am open to other names for the attributes, so long as they are clear and concise!

HerbDeutsch commented 5 years ago

Taking this from the email chain that had comments for documentation here: Herb Question: ¼ is an easy one since it is an exact decimal. What about 1/3 or other fraction that is a continuous decimal. It would have to terminate and not be exact.

John Response: Fractions expressed as numerator/denominator are allowed. The entire expression is expected to be placed into the NumberVotesFraction e.g. { “NumberVotes”: 1 “NumberVotesFraction”: “1/3” }

Herb: Response: OK. I’m good with that.