I'm assuming that you are asking about the "final" results. Anything before the close of polls is just exit polls and other types of polls. I worked at the polls in Phx Arizona.
You asked for technical so here goes. Here are the main tools
- Unofficial forms of voting that are not offically "counted" yet (these are printouts from the ballot boxes that can be used for approximatoins but not for official reporting numbers)
- They use a sample size of the the number of places reported officially.
- Exit polls they bug people leaving. "who did you vote for?" we had a guy outside asking questions and taking pictures of people.
- Comparison to previously performed polls
Each machine has an unofficial count of the ballots. It represents every vote but because of the way it is handled it is considered unofficial.
One Pollster (if that's a word) Goes and turns it in alone as soon as the polls close. Everyone else stays behind to close down the polling place. Since he goes alone he could tamper with it. All official ballots and documents are handled by two members of that polling location (the 'inspector' and the 'judge' who must be of different parties.)
This data can be useful for reporting purposes and it can be fairly accurate; however ultimately unofficial. This is the main source of info.
Once they have begun counting they use the current count as a sample size and have statisticians run approximations of what the population is.
They can have a previous poll that they use to compare it against if they are really desperate. They also can use the unofficial ballot count as a very close approximation of the population mean. They can use the standard error of the previous sample statistic (that was also calculated to represent the population parameter within a margin of error)
Theoretically they are supposed to take into account the sample quality. Certain areas are counted first that vote mostly for one party they should be treated as a sample that has a known bias.
Boring calculation below
(null hypothesis) H0= M(mew)=C(percentage of people voting for the thing or person)
The sample size will be the number of ballots counted = n
sigma = standard deviation
(x - x(bar))/(sigma/square root of N) = Z
(because the sample will be greater than 30 we can assume)
If that Z is larger or smaller than the confidence level (alpha) the news organization has agreed upon then they can make certain predictions of accurately of their polling information.