If you'd like to see additional details, you are welcome to review the statute passed by Scotland.
At a high level, the vote count takes place in rounds. For the first round, you count the first place votes. For subsequent rounds, you will either (1) transfer surplus votes from a candidate or (2) eliminate a candidate. We'll assume that you've read our STV overview and understand what surplus votes are.
You may find it helpful to review some Scottish STV election results while you are reading this.
Quota or ThresholdAll STV methods have a quota or winning threshold. The quota is computed using the number of non-empty votes. For example, at the time of this writing, this election had 2006 total votes, but 252 of them were empty, so the quota is computed based on the 1754 non-empty votes.
The quota is computed by (1) dividing the number of non-empty votes by the number of seats plus one, (2) adding one, and (3) discarding any fraction.
For example, with 1754 non-empty votes and 2 seats, we compute 1754/3 + 1 and discard any fraction, which gives a quota of 585.
First Place VotesThe first step is quite easy. All votes are assigned to their first choices.
Transfer Surplus vs. EliminateAt each round after the first, we need to either (1) transfer surplus votes from one candidate or (2) eliminate one candidate. The decision is easy. If at least one candidate has surplus votes, then we transfer surplus votes. If no candidates have surplus votes, then we eliminate one candidate.
Note that in each round we process exactly one candidate. If more than one candidate has surplus votes, then we select the candidate with the largest number of votes and transfer only that candidate's surplus votes. Other candidates with surplus votes will be processed in subsequent rounds. If no candidates have surplus votes, then one candidate with the fewest number of votes is eliminated.
Once a candidate has transferred surplus votes or been eliminated, that candidate can no longer receive any votes. For example, suppose in round 2 that A has a surplus and those surplus votes are transferred. Suppose in round 3, that candidate B is eliminated and some of B's votes rank A second. For B's votes that rank A second, those votes will pass over the second choice of A and transfer to the third choice.
Transfer Surplus VotesWhen transferring surplus votes from a candidate, we are actually transferring ALL votes received by that candidate, but we transfer them at a fraction of their value. The idea is that a quota of votes remain with the candidate and the surplus votes get counted towards the next choices on the ballots.
For example, suppose candidate A has 671 votes and that the quota is 585. A thus has 86 surplus votes (671 - 585 = 86) that need to be transferred.
Candidate A has 671 votes, so we transfer each of them 86/617 of their value. If we transfer 671 votes at a value of 86/671, then the total "number" of votes transferred is 86.
Fractions are hard (for people and computers) so the transfer value of 86/671 needs to be converted to a number, and the result is 0.128166915.... Most fractions result in an infinitely long number so the Scottish rules truncate to 5 digits or 0.12816. Accordingly, each of A's votes gets transferred at a value of 0.12816 to the next choice on the ballot.
Each candidate receiving votes from A may now have a total number of votes that isn't a whole number. For example, candidate B may have had 478 votes before the transfer, received 26.65728 votes (208 of A's votes at a value of 0.12816), and now have 504.65728 votes.
Note that candidate B now has some votes with a value of 1 (e.g., the votes where B was ranked first) and some votes with a value of 0.12816 (the votes received in the surplus transfer from A).
Eliminate Candidate and Transfer VotesEliminating a candidate is much simpler. All votes get transferred to their next choices at the same value that they currently have.
Exhausted VotesLooking at Scottish STV results, you'll see a bar for "Exhausted" votes. An exhausted vote occurs when a ballot has no next choice. This can happen when you transfer surplus votes or votes from an eliminated candidate. For example, if a voter ranked candidate A first and didn't rank anyone else, then that vote would become exhausted when transferring surplus votes from A and 0.12816 would be added to the exhausted bar.
TiesTies can occur when you are selecting a surplus to transfer or when selecting a candidate to eliminate. For example, suppose both candidate A and candidate B have surplus votes and that they have the same number of votes. We now need to pick either A or B to transfer surplus votes.
With Scottish STV, ties are broken by looking to previous rounds. Suppose A and B are tied at round 3. To break the tie, we look to round 2 and see which candidate had more votes. If A had more votes than B at round 2, then we select A to transfer surplus votes at round 3. If A and B were also tied at round 2, then we look to round 1. If they are tied at round 1, then we make a random selection.