Voting Project Needs Python People

Andrew Dalke adalke at
Thu Jul 24 09:29:22 CEST 2003

Alan Dechert:
> BTW, do you know about cumulative binomial distribution?  I think we need
> include a tool like this to give us some "C.L" (confidence level) short of
> verifying that every single paper ballot matches its electronic
> What I really want is a calculator.  Do you know of a free calculator for
> this?  If not, could you make one? (for free, of course).

I don't know anything about it, although looking at it I think I understand
what it's trying to do.  Here's the equation for those following along

   1 - C.L. = Sum  C(N, k) * (1-R)**k * R**(N-k)

where R(N, k) = N! / (k! * (N-k)!)

and C.L. is the confidence level,
N is the number of votes tested
r is the maximum allowable number of errors, and
R is the reliability (scanning errors, attempts at voting fraud, etc.)

The problem is, I don't see how to use it.  Here's the case I
had in mind.  Suppose you have 100,000 votes and want to
be 90% certain that there is no more than 1% error.  This means
you'll need to retest N ballots (the ballots "under test").  Then
the variables are:

  C.L. = 0.90
  N = to be determined
  r = N * 0.01
  R = ???

and I just don't know what to use for R.  Let's say it's <0.1%.  Then

  1 - 0.9 = Sum   C(100000, k) * (1-0.001)**k * (0.001) ** (N-k)

and solve for N.

I wouldn't want to write a calculator for it without the verification of
someone who knows it better than I do.  The only way I know to
solve this iteratively, and given the large and small numbers involved,
I would worry about numerical problems like overflow and underflow.
(OTOH, for those cases, approximations like the Stirling expansion
for factorials come into play.  But my math for this is entirely too

So no, I can't help you further than this.

BTW, I don't think you need to distribute a calculator for this.  I think
you just need some tables which give values for a few select points,
as in:

  #     |  75% certain      |  90%  |  98%  ||  90%  | 98%
ballots |  of no more than  |  ..   |       ||       |
        |    1% error rate  |  1%   |   1%  ||   5%  |  5%
100     |      values ....
200     |      values ....

                    dalke at

More information about the Python-list mailing list