<s>
In	O
statistics	O
,	O
the	O
binomial	B-General_Concept
test	I-General_Concept
is	O
an	O
exact	B-General_Concept
test	I-General_Concept
of	O
the	O
statistical	B-General_Concept
significance	I-General_Concept
of	O
deviations	O
from	O
a	O
theoretically	O
expected	O
distribution	O
of	O
observations	O
into	O
two	O
categories	O
using	O
sample	O
data	O
.	O
</s>
<s>
The	O
binomial	B-General_Concept
test	I-General_Concept
is	O
useful	O
to	O
test	O
hypotheses	O
about	O
the	O
probability	O
(	O
)	O
of	O
success	O
:	O
</s>
<s>
If	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
were	O
correct	O
,	O
then	O
the	O
expected	O
number	O
of	O
successes	O
would	O
be	O
.	O
</s>
<s>
For	O
a	O
one-tailed	B-General_Concept
test	I-General_Concept
,	O
this	O
is	O
straightforward	O
to	O
compute	O
.	O
</s>
<s>
Calculating	O
a	O
-value	O
for	O
a	O
two-tailed	B-General_Concept
test	I-General_Concept
is	O
slightly	O
more	O
complicated	O
,	O
since	O
a	O
binomial	O
distribution	O
is	O
n't	O
symmetric	O
if	O
.	O
</s>
<s>
This	O
means	O
that	O
we	O
ca	O
n't	O
just	O
double	O
the	O
-value	O
from	O
the	O
one-tailed	B-General_Concept
test	I-General_Concept
.	O
</s>
<s>
One	O
common	O
use	O
of	O
the	O
binomial	B-General_Concept
test	I-General_Concept
is	O
in	O
the	O
case	O
where	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
is	O
that	O
two	O
categories	O
are	O
equally	O
likely	O
to	O
occur	O
(	O
such	O
as	O
a	O
coin	O
toss	O
)	O
,	O
implying	O
a	O
null	B-General_Concept
hypothesis	I-General_Concept
.	O
</s>
<s>
However	O
,	O
as	O
the	O
example	O
below	O
shows	O
,	O
the	O
binomial	B-General_Concept
test	I-General_Concept
is	O
not	O
restricted	O
to	O
this	O
case	O
.	O
</s>
<s>
When	O
there	O
are	O
more	O
than	O
two	O
categories	O
,	O
and	O
an	O
exact	B-General_Concept
test	I-General_Concept
is	O
required	O
,	O
the	O
multinomial	B-General_Concept
test	I-General_Concept
,	O
based	O
on	O
the	O
multinomial	O
distribution	O
,	O
must	O
be	O
used	O
instead	O
of	O
the	O
binomial	B-General_Concept
test	I-General_Concept
.	O
</s>
<s>
For	O
large	O
samples	O
such	O
as	O
the	O
example	O
below	O
,	O
the	O
binomial	O
distribution	O
is	O
well	O
approximated	O
by	O
convenient	O
continuous	O
distributions	O
,	O
and	O
these	O
are	O
used	O
as	O
the	O
basis	O
for	O
alternative	O
tests	O
that	O
are	O
much	O
quicker	O
to	O
compute	O
,	O
such	O
as	O
Pearson	B-General_Concept
's	I-General_Concept
chi-squared	I-General_Concept
test	I-General_Concept
and	O
the	O
G-test	B-General_Concept
.	O
</s>
<s>
However	O
,	O
for	O
small	O
samples	O
these	O
approximations	O
break	O
down	O
,	O
and	O
there	O
is	O
no	O
alternative	O
to	O
the	O
binomial	B-General_Concept
test	I-General_Concept
.	O
</s>
<s>
where	O
is	O
the	O
number	O
of	O
successes	O
observed	O
in	O
a	O
sample	O
of	O
size	O
and	O
is	O
the	O
probability	O
of	O
success	O
according	O
to	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
.	O
</s>
<s>
An	O
improvement	O
on	O
this	O
approximation	O
is	O
possible	O
by	O
introducing	O
a	O
continuity	B-General_Concept
correction	I-General_Concept
:	O
</s>
<s>
For	O
very	O
large	O
,	O
this	O
continuity	B-General_Concept
correction	I-General_Concept
will	O
be	O
unimportant	O
,	O
but	O
for	O
intermediate	O
values	O
,	O
where	O
the	O
exact	O
binomial	B-General_Concept
test	I-General_Concept
does	O
n't	O
work	O
,	O
it	O
will	O
yield	O
a	O
substantially	O
more	O
accurate	O
result	O
.	O
</s>
<s>
Suppose	O
we	O
have	O
a	O
board	O
game	O
that	O
depends	O
on	O
the	O
roll	O
of	O
one	O
die	B-Language
and	O
attaches	O
special	O
importance	O
to	O
rolling	O
a	O
6	O
.	O
</s>
<s>
In	O
a	O
particular	O
game	O
,	O
the	O
die	B-Language
is	O
rolled	O
235	O
times	O
,	O
and	O
6	O
comes	O
up	O
51	O
times	O
.	O
</s>
<s>
We	O
have	O
now	O
observed	O
that	O
the	O
number	O
of	O
6s	O
is	O
higher	O
than	O
what	O
we	O
would	O
expect	O
on	O
average	O
by	O
pure	O
chance	O
had	O
the	O
die	B-Language
been	O
a	O
fair	O
one	O
.	O
</s>
<s>
But	O
,	O
is	O
the	O
number	O
significantly	O
high	O
enough	O
for	O
us	O
to	O
conclude	O
anything	O
about	O
the	O
fairness	O
of	O
the	O
die	B-Language
?	O
</s>
<s>
This	O
question	O
can	O
be	O
answered	O
by	O
the	O
binomial	B-General_Concept
test	I-General_Concept
.	O
</s>
<s>
Our	O
null	B-General_Concept
hypothesis	I-General_Concept
would	O
be	O
that	O
the	O
die	B-Language
is	O
fair	O
(	O
probability	O
of	O
each	O
number	O
coming	O
up	O
on	O
the	O
die	B-Language
is	O
1/6	O
)	O
.	O
</s>
<s>
As	O
we	O
have	O
observed	O
a	O
value	O
greater	O
than	O
the	O
expected	O
value	O
,	O
we	O
could	O
consider	O
the	O
probability	O
of	O
observing	O
51	O
6s	O
or	O
higher	O
under	O
the	O
null	O
,	O
which	O
would	O
constitute	O
a	O
one-tailed	B-General_Concept
test	I-General_Concept
(	O
here	O
we	O
are	O
basically	O
testing	O
whether	O
this	O
die	B-Language
is	O
biased	O
towards	O
generating	O
more	O
6s	O
than	O
expected	O
)	O
.	O
</s>
<s>
In	O
order	O
to	O
calculate	O
the	O
probability	O
of	O
51	O
or	O
more	O
6s	O
in	O
a	O
sample	O
of	O
235	O
under	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
we	O
add	O
up	O
the	O
probabilities	O
of	O
getting	O
exactly	O
51	O
6s	O
,	O
exactly	O
52	O
6s	O
,	O
and	O
so	O
on	O
up	O
to	O
probability	O
of	O
getting	O
exactly	O
235	O
6s	O
:	O
</s>
<s>
If	O
we	O
have	O
a	O
significance	B-General_Concept
level	I-General_Concept
of	O
5%	O
,	O
then	O
this	O
result	O
(	O
0.02654	O
<	O
5%	O
)	O
indicates	O
that	O
we	O
have	O
evidence	O
that	O
is	O
significant	O
enough	O
to	O
reject	O
the	O
null	B-General_Concept
hypothesis	I-General_Concept
that	O
the	O
die	B-Language
is	O
fair	O
.	O
</s>
<s>
Normally	O
,	O
when	O
we	O
are	O
testing	O
for	O
fairness	O
of	O
a	O
die	B-Language
,	O
we	O
are	O
also	O
interested	O
if	O
the	O
die	B-Language
is	O
biased	O
towards	O
generating	O
fewer	O
6s	O
than	O
expected	O
,	O
and	O
not	O
only	O
more	O
6s	O
as	O
we	O
considered	O
in	O
the	O
one-tailed	B-General_Concept
test	I-General_Concept
above	O
.	O
</s>
<s>
In	O
order	O
to	O
consider	O
both	O
the	O
biases	O
,	O
we	O
use	O
a	O
two-tailed	B-General_Concept
test	I-General_Concept
.	O
</s>
<s>
Note	O
that	O
to	O
do	O
this	O
we	O
cannot	O
simply	O
double	O
the	O
one-tailed	B-General_Concept
p-value	B-General_Concept
unless	O
the	O
probability	O
of	O
the	O
event	O
is	O
1/2	O
.	O
</s>
<s>
There	O
are	O
two	O
methods	O
to	O
define	O
the	O
two-tailed	O
p-value	B-General_Concept
.	O
</s>
<s>
In	O
both	O
cases	O
,	O
the	O
two-tailed	B-General_Concept
test	I-General_Concept
reveals	O
significance	O
at	O
the	O
5%	O
level	O
,	O
indicating	O
that	O
the	O
number	O
of	O
6s	O
observed	O
was	O
significantly	O
different	O
for	O
this	O
die	B-Language
than	O
the	O
expected	O
number	O
at	O
the	O
5%	O
level	O
.	O
</s>
<s>
Binomial	B-General_Concept
tests	I-General_Concept
are	O
available	O
in	O
most	O
software	O
used	O
for	O
statistical	O
purposes	O
.	O
</s>
<s>
In	O
R	B-Language
the	O
above	O
example	O
could	O
be	O
calculated	O
with	O
the	O
following	O
code	O
:	O
</s>
<s>
In	O
Java	B-Language
using	O
the	O
Apache	B-Language
Commons	I-Language
library	O
:	O
</s>
<s>
In	O
Python	B-Language
,	O
use	O
SciPy	B-Application
's	O
:	O
</s>
<s>
In	O
MATLAB	B-Language
,	O
use	O
,	O
which	O
is	O
available	O
via	O
Mathworks	O
 '	O
community	O
File	O
Exchange	O
website	O
.	O
</s>
<s>
myBinomTest	O
will	O
directly	O
calculate	O
the	O
p-value	B-General_Concept
for	O
the	O
observations	O
given	O
the	O
hypothesized	O
probability	O
of	O
a	O
success	O
.	O
</s>
<s>
(	O
generally	O
two-tailed	O
,	O
but	O
can	O
optionally	O
perform	O
a	O
one-tailed	B-General_Concept
test	I-General_Concept
)	O
.	O
</s>
<s>
In	O
Stata	B-Algorithm
,	O
use	O
bitest	O
.	O
</s>
<s>
In	O
Microsoft	B-Application
Excel	I-Application
,	O
use	O
Binom.Dist	O
.	O
</s>
