<?xml version="1.0"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "mathml.dtd"> 
<?xml-stylesheet type="text/css" href="thesis.css"?> 
<html  
xmlns="http://www.w3.org/1999/xhtml"  
><head><title>3.3 Binomial Tail calculation techniques</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.cis.ohio-state.edu/~gurari/TeX4ht/mn.html)" /> 
<meta name="originator" content="TeX4ht (http://www.cis.ohio-state.edu/~gurari/TeX4ht/mn.html)" /> 
<!-- 3,early_,early^,xhtml,mozilla --> 
<meta name="src" content="thesis.tex" /> 
<meta name="date" content="2002-08-28 13:56:00" /> 
<link rel="stylesheet" type="text/css" href="thesis.css" /> 
</head><body 
>
   <div class="crosslinks"><p class="noindent">[<a 
href="thesisse12.xml" >next</a>] [<a 
href="thesisse10.xml" >prev</a>] [<a 
href="thesisse10.xml#tailthesisse10.xml" >prev-tail</a>] [<a 
href="#tailthesisse11.xml">tail</a>] [<a 
href="thesisch3.xml#thesisse11.xml" >up</a>] </p></div>
   <h3 class="sectionHead"><span class="titlemark">3.3. </span> <a 
  name="x17-250003.3"></a>Binomial Tail calculation techniques</h3>
<!--l. 698--><p class="noindent">How quickly can we calculate the binomial coefficient, <!--l. 698--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
<mrow><mi 
>k</mi></mrow></mfrac></mfenced> </mrow></math>? This
question is important to answer because we will apply the bounds derived later to real
problems, and this application will require calculation of Binomial coefficients and
Binomial tails.
</p><!--l. 703--><p class="indent">   The answer is: not very fast. It is an open problem to calculate <!--l. 703--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
<mrow><mi 
>k</mi></mrow></mfrac></mfenced> </mrow></math> in time not exponential
in <!--l. 704--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><mo 
>log</mo><!--nolimits--><mi 
>m</mi></mrow></math> and <!--l. 704--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mo 
>log</mo><!--nolimits--><mi 
>k</mi></mrow></math> (the representation
length of <!--l. 705--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><mi 
>m</mi></mrow></math>
and <!--l. 705--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><mi 
>k</mi></mrow></math>).
In general, this problem is intractable. For example, we note that <!--l. 707--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="display">
<mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow>
                              <mi 
>m</mi></mrow>
<mrow><mfrac><mrow 
><mi 
>m</mi></mrow>
<mrow 
><mn>2</mn></mrow></mfrac></mrow></mfrac></mfenced> <mo 
class="MathClass-rel">&#x2243;</mo> <mfrac><mrow 
><msup><mrow 
><mn>2</mn></mrow><mrow 
><mi 
>m</mi></mrow></msup 
></mrow> 
<mrow 
><msqrt><mi 
></mi><mrow><mi 
>m</mi></mrow></msqrt></mrow></mfrac>
</mrow></math>
which has an asymptotic representation length of <!--l. 709--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>. Since it
takes <!--l. 710--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
time to write the answer, we can not hope to compute the answer in less than <!--l. 711--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> time. The
problem is more difficult than this though - even calculating the most significant bits of the appears
to take <!--l. 712--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
time.
</p><!--l. 715--><p class="indent">   Our real goal is not merely calculating binomial coefficients but rather calculating the probability
of a tail, <!--l. 716--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">        <mrow 
><!--mstyle 
class="text"--><mtext class="textrm">Bin</mtext><!--/mstyle--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi><mo 
class="MathClass-punc">,</mo><mi 
>k</mi><mo 
class="MathClass-punc">,</mo><mi 
>p</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>.
How can we calculate the tail probability quickly? For all approaches, it is necessary to calculate <!--l. 718--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
                                                                     

                                                                     
<mrow 
><mo 
>log</mo><!--nolimits--><!--mstyle 
class="text"--><mtext class="textrm">Bin</mtext><!--/mstyle--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi><mo 
class="MathClass-punc">,</mo><mi 
>k</mi><mo 
class="MathClass-punc">,</mo><mi 
>p</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> rather than
<!--l. 718--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">     <mrow 
><!--mstyle 
class="text"--><mtext class="textrm">Bin</mtext><!--/mstyle--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi><mo 
class="MathClass-punc">,</mo><mi 
>k</mi><mo 
class="MathClass-punc">,</mo><mi 
>p</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
to avoid underflow issues. This is generally possible because we can calculate <!--l. 719--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mo 
>log</mo><!--nolimits--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>a</mi> <mo 
class="MathClass-bin">+</mo> <mi 
>b</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> given <!--l. 720--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mo 
>log</mo><!--nolimits--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>a</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> and <!--l. 720--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mo 
>log</mo><!--nolimits--><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>b</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
without losing precision.
</p><!--l. 722--><p class="indent">   There are several possible approaches of increasing sophistication:
</p><!--l. 724--><p class="indent">
           </p><ol type="1" class="enumerate1" start="1" 
>
        <li class="enumerate"><a 
  name="x17-25002x1"></a>Calculate <!--l. 725--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
 <mrow><mi 
>i</mi></mrow></mfrac></mfenced> </mrow></math>
        independently from <!--l. 725--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mi 
>i</mi> <mo 
class="MathClass-rel">=</mo> <mn>0</mn></mrow></math>
        to <!--l. 725--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mi 
>i</mi> <mo 
class="MathClass-rel">=</mo> <mi 
>k</mi></mrow></math>
        and use the results to calculate the sum, <!--l. 726--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><msubsup><mrow 
><mo 
class="MathClass-op">&#x2211;</mo>
  </mrow><mrow 
><mi 
>i</mi><mo 
class="MathClass-rel">=</mo><mn>0</mn></mrow><mrow 
><mi 
>k</mi></mrow></msubsup 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
 <mrow><mi 
>i</mi></mrow></mfrac></mfenced> <msup><mrow 
><mi 
>p</mi></mrow><mrow 
><mi 
>i</mi></mrow></msup 
><msup><mrow 
><mrow><mo 
class="MathClass-open">(</mo><mrow><mn>1</mn> <mo 
class="MathClass-bin">&#x2212;</mo> <mi 
>p</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow><mrow 
><mi 
>m</mi><mo 
class="MathClass-bin">&#x2212;</mo><mi 
>i</mi></mrow></msup 
></mrow></math>.
           </li>
        <li class="enumerate"><a 
  name="x17-25004x2"></a>Calculate Pascal&#x2019;s triangle and extract the Binomial coefficients.
           </li>
        <li class="enumerate"><a 
  name="x17-25006x3"></a>Use the fact that <!--l. 729--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="display">      <mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow>
                                      <mi 
>m</mi></mrow> 
<mrow><mi 
>i</mi> <mo 
class="MathClass-bin">+</mo> <mn>1</mn></mrow></mfrac></mfenced> <mo 
class="MathClass-rel">=</mo>            <mfrac><mrow 
><mi 
>m</mi><mi 
>!</mi></mrow> 
<mrow 
><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi> <mo 
class="MathClass-bin">&#x2212;</mo> <mi 
>i</mi> <mo 
class="MathClass-bin">&#x2212;</mo> <mn>1</mn></mrow><mo 
class="MathClass-close">)</mo></mrow><mi 
>!</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>i</mi> <mo 
class="MathClass-bin">+</mo> <mn>1</mn></mrow><mo 
class="MathClass-close">)</mo></mrow><mi 
>!</mi></mrow></mfrac>
</mrow></math>
                                                                     

                                                                     
        <!--l. 731--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="display">      <mrow 
>
<mo 
class="MathClass-rel">=</mo> <mfrac><mrow 
><mi 
>m</mi> <mo 
class="MathClass-bin">&#x2212;</mo> <mi 
>i</mi></mrow> 
<mrow 
><mi 
>i</mi> <mo 
class="MathClass-bin">+</mo> <mn>1</mn></mrow></mfrac>      <mfrac><mrow 
><mi 
>m</mi><mi 
>!</mi></mrow> 
<mrow 
><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi> <mo 
class="MathClass-bin">&#x2212;</mo> <mi 
>i</mi></mrow><mo 
class="MathClass-close">)</mo></mrow><mi 
>!</mi><mi 
>i</mi><mi 
>!</mi></mrow></mfrac> <mo 
class="MathClass-rel">=</mo> <mfrac><mrow 
><mi 
>m</mi> <mo 
class="MathClass-bin">&#x2212;</mo> <mi 
>i</mi></mrow> 
<mrow 
><mi 
>i</mi> <mo 
class="MathClass-bin">+</mo> <mn>1</mn></mrow></mfrac>  <mfenced separators="" 
open="("  close=")" ><mrow><mtable  
equalrows="false" equalcolumns="false" class="array"><mtr><mtd 
class="array"  columnalign="center"><mi 
>m</mi></mtd>
</mtr><mtr><mtd 
class="array"  columnalign="center"> <mi 
>i</mi> </mtd></mtr>  <!--c--></mtable>                                                                                       </mrow></mfenced>
</mrow></math>
           </li>
        <li class="enumerate"><a 
  name="x17-25008x4"></a>Calculate <!--l. 737--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
<mrow><mi 
>k</mi></mrow></mfrac></mfenced> </mrow></math>
        directly and then <!--l. 737--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow> <mi 
>m</mi></mrow>
<mrow><mi 
>i</mi><mo 
class="MathClass-bin">&#x2212;</mo><mn>1</mn></mrow></mfrac></mfenced></mrow></math>
        given <!--l. 738--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mfenced separators="" 
open="(" close=")"><mfrac linethickness="0.0pt"><mrow><mi 
>m</mi></mrow>
 <mrow><mi 
>i</mi></mrow></mfrac></mfenced> </mrow></math>
        until the added quantity falls below the machine precision.</li></ol>
<!--l. 739--><p class="nopar">Approaches (1) and (2) both require <!--l. 740--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">      <mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><msup><mrow 
><mi 
>m</mi></mrow><mrow 
><mn>2</mn></mrow></msup 
></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
work while approaches (3) and (4) require merely <!--l. 741--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> work.
We will use approach (4) here. Yet, as noted in the beginning of this section, <!--l. 742--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math>
is still sometimes too expensive for us. Luckily, there exist some quick
approximations which can reduce the computation to constant time (or <!--l. 744--><math 
xmlns="http://www.w3.org/1998/Math/MathML" 
mode="inline">
<mrow 
><mi 
>O</mi><mrow><mo 
class="MathClass-open">(</mo><mrow><mo 
>log</mo><!--nolimits--><mi 
>m</mi></mrow><mo 
class="MathClass-close">)</mo></mrow></mrow></math> time
depending on your computational model).
</p><!--l. 748--><p class="indent">
                                                                     

                                                                     
</p>
   <div class="crosslinks"><p class="noindent">[<a 
href="thesisse12.xml" >next</a>] [<a 
href="thesisse10.xml" >prev</a>] [<a 
href="thesisse10.xml#tailthesisse10.xml" >prev-tail</a>] [<a 
href="thesisse11.xml" >front</a>] [<a 
href="thesisch3.xml#thesisse11.xml" >up</a>] </p></div><a 
  name="tailthesisse11.xml"></a>  
</body> 
</html> 
