
A function that can be used in Formulas. The complement of the cumulative binomial distribution.
binomialQ (p, k, n)
A die is suspected to yield more sixes than a perfect die would do. In order to test this suspicion, you throw it 1,000 times. The result is 211 sixes.
The probability that a perfect die yields at least 211 sixes is, according to Calculator..., binomialQ (1/6, 211, 1000)
= 0.000152.
You convert 1000 values of pitch targets in Hz to the nearest note on the piano keyboard. 597 of those values turn out to be in the A, B, C, D, E, F, or G regions (the white keys), and 403 values turn out to be in the A#, C#, D#, F#, or G# regions (the black keys). Do our subjects have a preference for the white keys? The following script computes the probability that in the case of no preference the subjects would target the white keys at least 597 times. This is compared with a χ^{2} test.
a = 597
b = 403
p = 7/12 ; no preference
writeInfoLine: "*** Binomial test ", a, ", ", b, ", p = ", fixed$ (p, 6), " ***"
pbin = binomialQ (p, a, a+b)
appendInfoLine: "P (binomial) = ", fixed$ (pbin, 6)
# Chisquare test with Yates correction:
x2 = (a  1/2  p * (a+b))^2/(p*(a+b)) + (b + 1/2  (1p) * (a+b))^2/((1p)*(a+b))
px2 = chiSquareQ (x2, 1)
appendInfoLine: "P (chisquare) = ", fixed$ (px2, 6)
The result is:
*** Binomial test 597, 403, p = 0.583333 ***
P (binomial) = 0.199330
P (chisquare) = 0.398365
The χ^{2} test is twosided (it signals a preference for the white or for the black keys), so it has twice the probability of the binomial test.
We cannot conclude from this test that people have a preference for the white keys. Of course, we cannot conclude either that people do not have such a preference.
© ppgb, February 23, 2014