I was looking for the same thing myself... And I found it. I don't think I can insert mathML here, and I think code is a much better explanation than stupid mathy symbols, sere's some code I wrote minus some comments. It could be written to be much faster, but it is plenty fast enough for the number of trials we'd be talking about. Can you read Python?

def factorial(x):

if x < 0: raise ValueError("Factorials for numbers less than zero are undefined")

if x <= 1: return 1

return reduce(operator.mul, xrange(2, x+1))

def binomial(n, k, p=0.5):

if k > n:

raise ValueError("Number of occurances (%d) exceeds number of trials (%d)." % (k, n))

q = 1.0 - p

return pow(p, k) * pow(q, n-k) * factorial(n) / (factorial(k) * factorial(n-k))

def abxBinomial(trials, correct):

if correct > trials:

raise ValueError("Number of correct ABX trials (%d) exceeds total number of trials (%d)." % (correct, trials)

return reduce(operator.add, map(lambda k: binomial(trials, k), range(correct, trials+1)))

Quick explanation:

factorial() does exactly what its name says. It computes the factorial of a number.

binomial() uses the binomial distribution function to compute the probability that there would be exactly k occurances of some event of probability p occuring in n trials.

abxBinomial() computes the ABX pval you want. It takes the sum of the binomial function for correct, correct+1 ... num_trials.

This method is fine for use on a computer/calculator, but if you're working it out by hand there are formulas which approximate the value more quickly (if less accurately). Also, be aware that it overflows doubles if you take 170+ trials.