(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.1' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 800306, 15245]*) (*NotebookOutlinePosition[ 800972, 15268]*) (* CellTagsIndexPosition[ 800928, 15264]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["1. SmirnovD Direct Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ SmirnovDKS1SidedRTProbRational which finds the right tail p-value using the \ SmirnovD direct formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(SmirnovDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Smirnov\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1944)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[1\ - \ d, \ 0]; \[IndentingNewLine]thirdTerm\ = \ d; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^sampleSize/thirdTerm, \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j)\)\ *\ thirdTerm^\((j\ - \ 1)\))\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[d\ *\ sumTerms, \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(SmirnovDKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["2. DwassD Direct Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ DwassDKS1SidedRTProbRational which finds the right tail p-value using the \ DwassD direct formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(DwassDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Dwass\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ d]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[1\ + \ d, \ 0]; \[IndentingNewLine]thirdTerm\ = \ \(-d\); \ \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j\ - \ 1)\)\ *\ thirdTerm^j)\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[1\ - \ \((d\ *\ sumTerms)\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(DwassDKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["3. SmirnovAltD Direct Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ SmirnovAltDKS1SidedRTProbRational which finds the right tail p-value using \ the SmirnovAltD direct formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(SmirnovAltDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Smirnov\ Alternate\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1941)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[sampleSize\ *\ \((1\ - \ d)\), \ 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[sampleSize\ *\ d, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^sampleSize/thirdTerm, \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ 1\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ 1\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j)\)\ *\ thirdTerm^\((j\ - \ 1)\))\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[ d\ *\ sumTerms*\ sampleSize^\((\(-\ sampleSize\)\ + \ 1)\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(SmirnovAltDKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["4. DwassAltD Direct Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ DwassAltDKS1SidedRTProbRational which finds the right tail p-value using the \ DwassAltD direct formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(DwassAltDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Dwass\ Alternate\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ \ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ d]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[sampleSize\ + \ d\ *\ sampleSize, \ 0]; \[IndentingNewLine]thirdTerm\ = \ \(-d\)\ *\ sampleSize; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ 1\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ 1\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j\ - \ 1)\)\ *\ thirdTerm^j)\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[ 1\ - \ \((d\ *\ sumTerms/sampleSize^\((sampleSize\ - \ 1)\))\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(DwassAltDKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["5. SmirnovI Iterative Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ SmirnovIKS1SidedRTProbRational which finds the right tail p-value using the \ SmirnovI iterative formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(SmirnovIKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ sumTerms, \ NminusjPlusOne, \ dN, \ dNPlusj, \ dNPlusjMinusOne, \ NminusdNMinusj, \ NminusdNMinusjPlusOne}, \[IndentingNewLine] (*\ Smirnov\ Iterative\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1944)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]sumTerms\ = \ Rationalize[\ \((1\ - \ d)\)^sampleSize, \ 0]; \[IndentingNewLine]term\ = \ sumTerms; \[IndentingNewLine]NminusjPlusOne\ = \ Rationalize[sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]dN\ = \ Rationalize[d\ *\ sampleSize, \ 0]; \[IndentingNewLine]dNPlusj\ = \ dN; \[IndentingNewLine]dNPlusjMinusOne\ = \ Rationalize[\ dNPlusj\ - \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusj\ = \ Rationalize[sampleSize\ - \ dN, \ 0]; \[IndentingNewLine]NminusdNMinusjPlusOne\ = \ Rationalize[NminusdNMinusj\ + \ 1, \ 0]; \[IndentingNewLine]If[ jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]NminusjPlusOne\ = \ Rationalize[NminusjPlusOne\ - \ 1, \ 0]; \[IndentingNewLine]dNPlusj\ = \ Rationalize[dNPlusj\ + \ 1\ , \ 0]; \[IndentingNewLine]dNPlusjMinusOne\ = \ Rationalize[\ dNPlusjMinusOne\ + \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusj\ = \ Rationalize[NminusdNMinusj\ - \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusjPlusOne\ = \ Rationalize[NminusdNMinusjPlusOne\ - \ 1, \ 0]; \[IndentingNewLine]If[\ NminusdNMinusj\ > \ 0, \[IndentingNewLine]term\ = \ Rationalize[\ \((\((NminusjPlusOne\ *\ dNPlusj)\)/\((j\ *\ NminusdNMinusj)\))\)*\ \((1\ - \ \((1/ NminusdNMinusjPlusOne)\))\)^ NminusjPlusOne\ *\ \((1\ + \ \((1/ dNPlusjMinusOne)\))\)^\((j - 2)\)*term, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[sumTerms\ + term, \ 0];\[IndentingNewLine]];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[sumTerms, \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SmirnovIKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["6. DwassI Iterative Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ DwassIKS1SidedRTProbRational which finds the right tail p-value using the \ DwassI iterative formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(DwassIKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ sumTerms, \ Nminusj, \ dN, \ dNPlusjPlusOne, \ NminusdNMinusjMinusOne}, \[IndentingNewLine] (*\ Dwass\ Iterative\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jLowLimit\ = \ Ceiling[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]sumTerms\ = \ Rationalize[\ d\ *\ \((1\ + \ d)\)^\((sampleSize\ - \ 1)\), \ 0]; \[IndentingNewLine]term\ = \ sumTerms; \[IndentingNewLine]Nminusj\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]dN\ = \ Rationalize[d\ *\ sampleSize, \ 0]; \[IndentingNewLine]dNPlusjPlusOne\ = \ Rationalize[dN\ + \ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusjMinusOne\ = \ Rationalize[\(-dN\)\ - \ 1, \ 0]; \[IndentingNewLine]If[ jLowLimit\ \[GreaterEqual] \ sampleSize, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]\(If[\ NminusdNMinusjMinusOne\ < \ 0, \[IndentingNewLine]Nminusj\ = \ Rationalize[Nminusj\ + \ 1, \ 0]; \[IndentingNewLine]dNPlusjPlusOne\ = \ Rationalize[dNPlusjPlusOne\ - \ 1\ , \ 0]; \[IndentingNewLine]NminusdNMinusjMinusOne\ = \ Rationalize[NminusdNMinusjMinusOne\ + \ 1, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[\ \((\ \((\((j\ + \ 1)\)\ *\ NminusdNMinusjMinusOne)\)/\((Nminusj\ *\ dNPlusjPlusOne)\))\)*\ \((1\ + \ \((1/ NminusdNMinusjMinusOne)\))\)^ Nminusj\ *\ \((1\ - \ \((1/dNPlusjPlusOne)\))\)^\((j - 1)\)*term, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[sumTerms\ + term, \ 0];\[IndentingNewLine]];\)\[IndentingNewLine], {j, \ sampleSize - 1, \ jLowLimit, \ \(-1\)}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[1\ - \ \ sumTerms, \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(DwassIKS1SidedRTRational[4/11, 11]\)\(\ \)\)\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["7. SmirnovAltI Iterative Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ SmirnovAltIKS1SidedRTProbRational which finds the right tail p-value using \ the SmirnovAltI iterative formula. Sample intermediate output is also \ given.\ \>", "Text"], Cell[BoxData[ \(SmirnovAltIKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ NpowerNminusOne, \ leftTailProbability, \ rightTailProbability, \ sumTerms, \ NminusjPlusOne, \ dN, \ dNPlusj, \ dNPlusjMinusOne, \ NminusdNMinusj, \ NminusdNMinusjPlusOne}, \[IndentingNewLine] (*\ Smirnov\ Alternate\ Iterative\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1944)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]NpowerNminusOne\ = \ Rationalize[sampleSize^sampleSize, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[\ NpowerNminusOne\ *\ \((1\ - \ d)\)^sampleSize, \ 0]; \[IndentingNewLine]term\ = \ sumTerms; \[IndentingNewLine]NminusjPlusOne\ = \ Rationalize[sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]dN\ = \ Rationalize[d\ *\ sampleSize, \ 0]; \[IndentingNewLine]dNPlusj\ = \ dN; \[IndentingNewLine]dNPlusjMinusOne\ = \ Rationalize[\ dNPlusj\ - \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusj\ = \ Rationalize[sampleSize\ - \ dN, \ 0]; \[IndentingNewLine]NminusdNMinusjPlusOne\ = \ Rationalize[NminusdNMinusj\ + \ 1, \ 0]; \[IndentingNewLine]If[ jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]NminusjPlusOne\ = \ Rationalize[NminusjPlusOne\ - \ 1, \ 0]; \[IndentingNewLine]dNPlusj\ = \ Rationalize[dNPlusj\ + \ 1\ , \ 0]; \[IndentingNewLine]dNPlusjMinusOne\ = \ Rationalize[\ dNPlusjMinusOne\ + \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusj\ = \ Rationalize[NminusdNMinusj\ - \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusjPlusOne\ = \ Rationalize[NminusdNMinusjPlusOne\ - \ 1, \ 0]; \[IndentingNewLine]If[\ NminusdNMinusj\ > \ 0, \[IndentingNewLine]term\ = \ Rationalize[\ \((\((NminusjPlusOne\ *\ dNPlusj)\)/\((j\ *\ NminusdNMinusj)\))\)*\ \((1\ - \ \((1/ NminusdNMinusjPlusOne)\))\)^ NminusjPlusOne\ *\ \((1\ + \ \((1/ dNPlusjMinusOne)\))\)^\((j - 2)\)*term, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[sumTerms\ + term, \ 0];\[IndentingNewLine]];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[sumTerms/NpowerNminusOne, \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(SmirnovAltIKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["8. DwassAltI Iterative Formula with Sample Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ DwassAltIKS1SidedRTProbRational which finds the right tail p-value using the \ DwassAltI iterative formula. Sample intermediate output is also given.\ \>", "Text"], Cell[BoxData[ \(DwassAltIKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ sumTerms, \ Nminusj, \ dN, \ dNPlusjPlusOne, \ NminusdNMinusjMinusOne}, \[IndentingNewLine] (*\ Dwass\ Alternate\ Iterative\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jLowLimit\ = \ Ceiling[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]Nminusj\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]dN\ = \ Rationalize[d\ *\ sampleSize, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[\ d\ *\ \((sampleSize\ + \ dN)\)^\((sampleSize\ - \ 1)\)\ , \ 0]; \[IndentingNewLine]term\ = \ sumTerms; \[IndentingNewLine]dNPlusjPlusOne\ = \ Rationalize[dN\ + \ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]NminusdNMinusjMinusOne\ = \ Rationalize[\(-dN\)\ - \ 1, \ 0]; \[IndentingNewLine]If[ jLowLimit\ \[GreaterEqual] \ sampleSize, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]\(If[\ NminusdNMinusjMinusOne\ < \ 0, \[IndentingNewLine]Nminusj\ = \ Rationalize[Nminusj\ + \ 1, \ 0]; \[IndentingNewLine]dNPlusjPlusOne\ = \ Rationalize[dNPlusjPlusOne\ - \ 1\ , \ 0]; \[IndentingNewLine]NminusdNMinusjMinusOne\ = \ Rationalize[NminusdNMinusjMinusOne\ + \ 1, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[\ \((\ \((\((j\ + \ 1)\)\ *\ NminusdNMinusjMinusOne)\)/\((Nminusj\ *\ dNPlusjPlusOne)\))\)*\ \((1\ + \ \((1/ NminusdNMinusjMinusOne)\))\)^ Nminusj\ *\ \((1\ - \ \((1/dNPlusjPlusOne)\))\)^\((j - 1)\)*term, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[sumTerms\ + term, \ 0];\[IndentingNewLine]];\)\[IndentingNewLine], {j, \ sampleSize - 1, \ jLowLimit, \ \(-1\)}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[1\ - \ \ sumTerms/sampleSize^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(DwassAltIKS1SidedRTRational[4/11, 11]\)], "Input"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["9. Daniels Recursion Formula with Sample Intermediate Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ DanilesKS1SidedRTProbRational which finds the p-value using the Daniels \ recursion formula. Sample intermediate output is given in subsection 9.1.\ \>", "Text"], Cell[BoxData[ \(DanielsKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ \ rightTailProbability, \ i, \ k, \ Q, \ newQvector, \ \ aSUBiMinusOne, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Daniels\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1\ = \ increasing\ amount\ of\ intermediate\ output\ *) \[IndentingNewLine] \ (*\ \ \ \ \ \ \ \ \ \ \ 2\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ Originally\ \ in\ Daniels\ \((1945)\)\ and\ reiterated\ by\ Noe\ and\ Vandewiele\ \ \(\((1968)\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ Formula\ used\ to\ \ implement\ the\ function\ from\ Noe\ and\ Vandewiele\ \(\((1968)\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ both\ \ positive\ and\ negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ H . \ E . \ Daniels\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ \ Proceedings\ of\ the\ Royal\ Statistical\ Society\ Series\ A\ \[IndentingNewLine]\ \ \ \ \ \ 183\ \((1945)\), \ pp . \ 405 - 435. \ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ Statistics\ 39\ \ \((1968)\), \ pp . \ 233 - 241. \ *) \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]Q\ \ = \ Array[0, \ {sampleSizePlusOne}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]Q[\([1]\)]\ \ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]Q[\([i + 1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]aSUBiMinusOne\ = \ Rationalize[Max[\((i - t)\)/sampleSize, \ 0]\ - \ 1, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< Start i = \>", \ i, \ "\< aSUBiMinusOne = \>", \ aSUBiMinusOne]]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[\ \(-\ Binomial[i, \ k]\)\ *\ Q[\([k + 1]\)]\ *\ aSUBiMinusOne^\((i - k)\), \ 0]; \[IndentingNewLine]Q[\([i + 1]\)]\ = \ Rationalize[Q[\([i + 1]\)]\ + \ term, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((i\ - \ k)\)\ /\ \((k\ + \ 1)\), \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< k = \>", \ k, \ "\< term = \>", \ term, \ "\< Q[[\>", \ i, "\<]] stored as Q[[\>", \ i + 1, "\<]] = \>", \ Q[\([i + 1]\)]\ ]];\[IndentingNewLine], {k, \ 0, \ i - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< End i = \>", \ i, \ \ "\< Q[[\>", \ i, "\<]] stored as Q[[\>", \ i + 1, "\<]] = \>", \ Q[\([i + 1]\)]\ ]];\[IndentingNewLine], {i, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ Q[\([sampleSizePlusOne]\)]; \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["9.1 Daniels Sample Intermediate Output", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(DanielsKS1SidedRTProbRational[4, \ 10, \ \ 11, \ 2]\)], "Input"], Cell[BoxData[ InterpretationBox[\("DanielsKS1SidedRTProbRational: sampleSize = "\ \[InvisibleSpace]11\[InvisibleSpace]" tIn = "\[InvisibleSpace]4\ \[InvisibleSpace]" t = "\[InvisibleSpace]4\[InvisibleSpace]" \ sampleSizePlusOne = "\[InvisibleSpace]12\), SequenceForm[ "DanielsKS1SidedRTProbRational: sampleSize = ", 11, " tIn = ", 4, " t = ", 4, " sampleSizePlusOne = ", 12], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]1\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-1\)\), SequenceForm[ " Start i = ", 1, " aSUBiMinusOne = ", -1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]1\[InvisibleSpace]" \ Q[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]2\ \[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " End i = ", 1, " Q[[", 1, "]] stored as Q[[", 2, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]2\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-1\)\), SequenceForm[ " Start i = ", 2, " aSUBiMinusOne = ", -1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]2\[InvisibleSpace]" \ Q[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]3\ \[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " End i = ", 2, " Q[[", 2, "]] stored as Q[[", 3, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]3\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-1\)\), SequenceForm[ " Start i = ", 3, " aSUBiMinusOne = ", -1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]3\[InvisibleSpace]" \ Q[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]4\ \[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " End i = ", 3, " Q[[", 3, "]] stored as Q[[", 4, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]4\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-1\)\), SequenceForm[ " Start i = ", 4, " aSUBiMinusOne = ", -1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]4\[InvisibleSpace]" \ Q[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]5\ \[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " End i = ", 4, " Q[[", 4, "]] stored as Q[[", 5, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]5\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(10\/11\)\)\), SequenceForm[ " Start i = ", 5, " aSUBiMinusOne = ", Rational[ -10, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]5\[InvisibleSpace]" \ Q[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]6\ \[InvisibleSpace]"]] = "\[InvisibleSpace]161050\/161051\), SequenceForm[ " End i = ", 5, " Q[[", 5, "]] stored as Q[[", 6, "]] = ", Rational[ 161050, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]6\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(9\/11\)\)\), SequenceForm[ " Start i = ", 6, " aSUBiMinusOne = ", Rational[ -9, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]6\[InvisibleSpace]" \ Q[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]7\ \[InvisibleSpace]"]] = "\[InvisibleSpace]1771443\/1771561\), SequenceForm[ " End i = ", 6, " Q[[", 6, "]] stored as Q[[", 7, "]] = ", Rational[ 1771443, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]7\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(8\/11\)\)\), SequenceForm[ " Start i = ", 7, " aSUBiMinusOne = ", Rational[ -8, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]7\[InvisibleSpace]" \ Q[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]8\ \[InvisibleSpace]"]] = "\[InvisibleSpace]19479720\/19487171\), SequenceForm[ " End i = ", 7, " Q[[", 7, "]] stored as Q[[", 8, "]] = ", Rational[ 19479720, 19487171]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]8\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(7\/11\)\)\), SequenceForm[ " Start i = ", 8, " aSUBiMinusOne = ", Rational[ -7, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]8\[InvisibleSpace]" \ Q[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]9\ \[InvisibleSpace]"]] = "\[InvisibleSpace]214018777\/214358881\), SequenceForm[ " End i = ", 8, " Q[[", 8, "]] stored as Q[[", 9, "]] = ", Rational[ 214018777, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]9\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(6\/11\)\)\), SequenceForm[ " Start i = ", 9, " aSUBiMinusOne = ", Rational[ -6, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]9\[InvisibleSpace]" \ Q[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]10\ \[InvisibleSpace]"]] = "\[InvisibleSpace]2345307750\/2357947691\), SequenceForm[ " End i = ", 9, " Q[[", 9, "]] stored as Q[[", 10, "]] = ", Rational[ 2345307750, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]10\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(5\/11\)\)\), SequenceForm[ " Start i = ", 10, " aSUBiMinusOne = ", Rational[ -5, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]10\[InvisibleSpace]" \ Q[["\[InvisibleSpace]10\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]11\ \[InvisibleSpace]"]] = "\[InvisibleSpace]25530513375\/25937424601\), SequenceForm[ " End i = ", 10, " Q[[", 10, "]] stored as Q[[", 11, "]] = ", Rational[ 25530513375, 25937424601]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Start i = "\[InvisibleSpace]11\[InvisibleSpace]" \ aSUBiMinusOne = "\[InvisibleSpace]\(-\(4\/11\)\)\), SequenceForm[ " Start i = ", 11, " aSUBiMinusOne = ", Rational[ -4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" End i = "\[InvisibleSpace]11\[InvisibleSpace]" \ Q[["\[InvisibleSpace]11\[InvisibleSpace]"]] stored as Q[["\[InvisibleSpace]12\ \[InvisibleSpace]"]] = "\[InvisibleSpace]273537428212\/285311670611\), SequenceForm[ " End i = ", 11, " Q[[", 11, "]] stored as Q[[", 12, "]] = ", Rational[ 273537428212, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" rightTailProbability = \ "\[InvisibleSpace]11774242399\/285311670611\), SequenceForm[ " rightTailProbability = ", Rational[ 11774242399, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["10. Noe Recursion Formula with Sample Intermediate Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ NoeKS1SidedRTProbRational which finds the p-value using the Noe recursion \ formula. Sample intermediate output is given in subsection 10.1.\ \>", "Text"], Cell[BoxData[ \(NoeKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ sampleSizePlusTwo, \ twiceSampleSize, \ rightTailProbability, \ i, \ k, \ m, FgammaSUBmVector, \ \ pSUBmVector, \ oldQvector, \ newQvector, \ alphaNumber, \ betaNumber, \ nextAlphaF, \ nextBetaF, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Noe\ and\ Vandewiele\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ Noe\ later\ added\ a\ \(\(correction\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2, \ 3, \ 4\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 5\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ The\ formula\ containing\ the\ correction\ implemented\ below\ is\ \ from\ *) \[IndentingNewLine]\ (*\ \ \ Shorack\ and\ Wellner, \ page\ 363, \ formulas\ \((24)\)\ through\ \(\((28)\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ only\ non - negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ Statistics\ 39\ \ \((1968)\), \ pp . \ 233 - 241. \ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ Annals\ of\ Mathematical\ Statistics\ 43\ \ \((1972)\), \ pp . \ 58 - 64. \ *) \[IndentingNewLine] (*\ G . \ R . \ Shorack\ and\ J . \ A . \ Wellner\[IndentingNewLine]\ \ \ \ \ Empirical\ processes\ with\ \ applications\ to\ statistics, \ \[IndentingNewLine]\ \ \ \ \ \ \(John\ Wiley\ \ &\)\ Sons, \ New\ York\ \(\((1986)\)\(.\)\)\ *) \[IndentingNewLine]sampleSize\ \ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]sampleSizePlusTwo\ = \ Rationalize[\ sampleSizePlusOne\ + \ 1, \ 0]; \[IndentingNewLine]twiceSampleSize\ = \ Rationalize[2\ *\ sampleSize, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne, \ "\< sampleSizePlusTwo = \>", \ sampleSizePlusTwo, \ "\< twiceSampleSize = \>", \ twiceSampleSize]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]oldQvector\ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]newQvector\ \ \ = \ Array[ 0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]FgammaSUBmVector\ \ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]pSUBmVector\ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]nextAlphaF\ \ = \ Rationalize[\ Max[\((1\ - \ t)\)/sampleSize, \ 0], 0]; \[IndentingNewLine]FgammaSUBmVector[\([1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]pSUBmVector[\([1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]FgammaSUBmVector[\([\ m]\)]\ = \ Rationalize[\ Max[\((m\ - \ 1\ - \ t)\)/sampleSize, \ 0], 0]; \[IndentingNewLine]pSUBmVector[\([m]\)]\ = \ Rationalize[ FgammaSUBmVector[\([m]\)]\ - \ FgammaSUBmVector[\([m - 1]\)], \ 0];\[IndentingNewLine], {m, \ 2, \ sampleSizePlusOne, \ 1}\[IndentingNewLine]]; \ \[IndentingNewLine]FgammaSUBmVector[\([sampleSizePlusTwo]\)]\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]pSUBmVector[\([sampleSizePlusTwo]\)]\ = \ Rationalize[1\ - \ FgammaSUBmVector[\([sampleSizePlusOne]\)], \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< FgammaSUBmVector = \>", \ FgammaSUBmVector]\ ]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< pSUBmVector = \>", \ pSUBmVector]\ ]; \[IndentingNewLine] (*\ Begin\ the\ recursion\ *) \[IndentingNewLine]oldQvector[\([1]\)]\ \ = \ 1; \[IndentingNewLine]oldQvector[\([2]\)]\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< m = \>", \ m]\ ]; \[IndentingNewLine]Do[\[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< i = \>", \ i]\ ]; \[IndentingNewLine]newQvector[\([i\ + \ 1]\)]\ = \ 0; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[oldQvector[\([k\ + \ 1]\)], \ 0]; \[IndentingNewLine]If[ i\ > \ k, \ \ term\ = \ Rationalize[ term\ *\ Binomial[i, \ k]\ *\ \ \ pSUBmVector[\([m + 1]\)]^\((i\ - \ k)\), \ 0]\ ]; \[IndentingNewLine]newQvector[\([i\ + \ 1]\)]\ = \ Rationalize[newQvector[\([i\ + \ 1]\)]\ + \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 5, \ Print["\< k = \>", \ k, \ "\< Binomial[i, k] = \>", \ binomialCoefficient, \ "\< oldQvector[[k + 1]] = \>", oldQvector[\([k\ + \ 1]\)], \ "\< pSUBmVector[[m+1]] = \>", \ pSUBmVector[\([m + 1]\)]\ ]\ ]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< k = \>", \ k, \ "\< term = \>", \ term, \ "\< newQvector[[\>", i, \ "\<]] stored as newQvector[[\>", \ i + 1, "\<]] = \>", \ newQvector[\([i\ + \ 1]\)]\ ]\ ]; \[IndentingNewLine]binomialCoefficient\ \ = \ Rationalize[binomialCoefficient\ *\ \((i\ - \ k)\)\ /\ \((k\ + \ 1)\), \ 0];\[IndentingNewLine], {k, \ 0, \ i, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< newQvector[[\>", \ i, "\<]] stored as newQvector[[\>", \ i + 1, \ "\<]] = \>", \ newQvector[\([i\ + \ 1]\)]]\ ];\[IndentingNewLine], {i, \ 0, \ \ m - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]newQvector[\([m + 1]\)]\ = \ Rationalize[0, 0]; \[IndentingNewLine]oldQvector\ = \ newQvector;\[IndentingNewLine], {m, \ 1, \ sampleSizePlusOne, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ newQvector[\([sampleSizePlusOne]\)]; \ \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["10.1 Noe Sample Intermediate Output", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(NoeKS1SidedRTProbRational[4, \ 10, \ \ 11, \ 2]\)], "Input"], Cell[BoxData[ InterpretationBox[\("NoeKS1SidedRTProbRational: sampleSize = "\ \[InvisibleSpace]11\[InvisibleSpace]" tIn = "\[InvisibleSpace]4\ \[InvisibleSpace]" t = "\[InvisibleSpace]4\[InvisibleSpace]" \ sampleSizePlusOne = "\[InvisibleSpace]12\[InvisibleSpace]" \ sampleSizePlusTwo = "\[InvisibleSpace]13\[InvisibleSpace]" twiceSampleSize \ = "\[InvisibleSpace]22\), SequenceForm[ "NoeKS1SidedRTProbRational: sampleSize = ", 11, " tIn = ", 4, " t = ", 4, " sampleSizePlusOne = ", 12, " sampleSizePlusTwo = ", 13, " twiceSampleSize = ", 22], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]1\), SequenceForm[ " m = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]2\), SequenceForm[ " m = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]3\), SequenceForm[ " m = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]4\), SequenceForm[ " m = ", 4], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]0\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]5\), SequenceForm[ " m = ", 5], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]1\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 1, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]1\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 1, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]1\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 1, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]1\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 1, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]6\), SequenceForm[ " m = ", 6], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]2\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 2, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]4\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 4, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]8\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 8, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]16\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 16, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]31\/161051\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 31, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]7\), SequenceForm[ " m = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]3\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 3, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]9\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 9, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]27\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 27, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]81\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 81, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]2\/1331\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 2, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]659\/1771561\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 659, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]8\), SequenceForm[ " m = ", 8], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]4\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]16\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 16, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]64\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 64, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]256\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 256, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]93\/14641\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 93, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]4020\/1771561\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 4020, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]13686\/19487171\), SequenceForm[ " newQvector[[", 7, "]] stored as newQvector[[", 8, "]] = ", Rational[ 13686, 19487171]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]9\), SequenceForm[ " m = ", 9], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]5\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 5, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]25\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 25, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]125\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 125, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]625\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 625, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]284\/14641\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 284, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]1413\/161051\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 1413, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]74874\/19487171\), SequenceForm[ " newQvector[[", 7, "]] stored as newQvector[[", 8, "]] = ", Rational[ 74874, 19487171]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]9\[InvisibleSpace]"]] = \ "\[InvisibleSpace]301321\/214358881\), SequenceForm[ " newQvector[[", 8, "]] stored as newQvector[[", 9, "]] = ", Rational[ 301321, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]10\), SequenceForm[ " m = ", 10], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]6\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 6, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]36\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 36, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]216\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 216, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]1296\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 1296, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]7775\/161051\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 7775, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]46568\/1771561\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 46568, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]276090\/19487171\), SequenceForm[ " newQvector[[", 7, "]] stored as newQvector[[", 8, "]] = ", Rational[ 276090, 19487171]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]9\[InvisibleSpace]"]] = "\[InvisibleSpace]1561952\/214358881\ \), SequenceForm[ " newQvector[[", 8, "]] stored as newQvector[[", 9, "]] = ", Rational[ 1561952, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]10\[InvisibleSpace]"]] = \ "\[InvisibleSpace]7196785\/2357947691\), SequenceForm[ " newQvector[[", 9, "]] stored as newQvector[[", 10, "]] = ", Rational[ 7196785, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]11\), SequenceForm[ " m = ", 11], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]7\/11\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", Rational[ 7, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]49\/121\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", Rational[ 49, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]343\/1331\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", Rational[ 343, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]2401\/14641\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", Rational[ 2401, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]16806\/161051\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 16806, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]117555\/1771561\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 117555, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]74460\/1771561\), SequenceForm[ " newQvector[[", 7, "]] stored as newQvector[[", 8, "]] = ", Rational[ 74460, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]9\[InvisibleSpace]"]] = "\[InvisibleSpace]5613849\/214358881\ \), SequenceForm[ " newQvector[[", 8, "]] stored as newQvector[[", 9, "]] = ", Rational[ 5613849, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]10\[InvisibleSpace]"]] = \ "\[InvisibleSpace]36267746\/2357947691\), SequenceForm[ " newQvector[[", 9, "]] stored as newQvector[[", 10, "]] = ", Rational[ 36267746, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]10\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]11\[InvisibleSpace]"]] = \ "\[InvisibleSpace]17038621\/2357947691\), SequenceForm[ " newQvector[[", 10, "]] stored as newQvector[[", 11, "]] = ", Rational[ 17038621, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" m = "\[InvisibleSpace]12\), SequenceForm[ " m = ", 12], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]0\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]1\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 0, "]] stored as newQvector[[", 1, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 1, "]] stored as newQvector[[", 2, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 2, "]] stored as newQvector[[", 3, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 3, "]] stored as newQvector[[", 4, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]1\), SequenceForm[ " newQvector[[", 4, "]] stored as newQvector[[", 5, "]] = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]6\[InvisibleSpace]"]] = "\[InvisibleSpace]161050\/161051\), SequenceForm[ " newQvector[[", 5, "]] stored as newQvector[[", 6, "]] = ", Rational[ 161050, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]7\[InvisibleSpace]"]] = "\[InvisibleSpace]1771443\/1771561\), SequenceForm[ " newQvector[[", 6, "]] stored as newQvector[[", 7, "]] = ", Rational[ 1771443, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]19479720\/19487171\ \), SequenceForm[ " newQvector[[", 7, "]] stored as newQvector[[", 8, "]] = ", Rational[ 19479720, 19487171]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]9\[InvisibleSpace]"]] = \ "\[InvisibleSpace]214018777\/214358881\), SequenceForm[ " newQvector[[", 8, "]] stored as newQvector[[", 9, "]] = ", Rational[ 214018777, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]10\[InvisibleSpace]"]] = \ "\[InvisibleSpace]2345307750\/2357947691\), SequenceForm[ " newQvector[[", 9, "]] stored as newQvector[[", 10, "]] = ", Rational[ 2345307750, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]10\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]11\[InvisibleSpace]"]] = \ "\[InvisibleSpace]25530513375\/25937424601\), SequenceForm[ " newQvector[[", 10, "]] stored as newQvector[[", 11, "]] = ", Rational[ 25530513375, 25937424601]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" \ newQvector[["\[InvisibleSpace]11\[InvisibleSpace]"]] stored as newQvector[["\ \[InvisibleSpace]12\[InvisibleSpace]"]] = \ "\[InvisibleSpace]273537428212\/285311670611\), SequenceForm[ " newQvector[[", 11, "]] stored as newQvector[[", 12, "]] = ", Rational[ 273537428212, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" rightTailProbability = \ "\[InvisibleSpace]11774242399\/285311670611\), SequenceForm[ " rightTailProbability = ", Rational[ 11774242399, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["11. Steck Recursion Formula with Sample Intermediate Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ SteckKS1SidedRTProbRational which finds the p-value using the Steck recursion \ formula. Sample intermediate output is given in subsection 11.1.\ \>", "Text"], Cell[BoxData[ \(SteckKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ \ rightTailProbability, \ i, \ j, \ m, \ b, \ P, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Steck\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ Formula\ \ used\ to\ implement\ the\ function\ from\ Shorack\ and\ Wellner\ \(\((1986)\)\ \(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ both\ \ positive\ and\ negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ G . \ P . \ Steck\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ \ Mathematical\ Statistics\ 40, \ \((1969)\), \ pp . \ 1449 - 1466. \ *) \[IndentingNewLine] (*\ G . \ R . \ Shorack\ and\ J . \ A . \ Wellner\[IndentingNewLine]\ \ \ \ \ Empirical\ processes\ with\ \ applications\ to\ statistics, \ \[IndentingNewLine]\ \ \ \ \ \ \(John\ Wiley\ \ &\)\ Sons, \ New\ York\ \(\((1986)\)\(.\)\)\ *) \[IndentingNewLine]sampleSize\ \ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]P\ \ = \ Array[0, \ {sampleSizePlusOne}]; \[IndentingNewLine]b\ = \ Array[0, \ {sampleSize}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]P[\([1]\)]\ \ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]b[\([j]\)]\ = \ Rationalize[Min[\((j\ - \ 1\ + \ t)\)/sampleSize, \ 1], \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< b[[\>", \ j, \ "\<]] = \>", \ b[\([j]\)]\ \ ]];\[IndentingNewLine], {j, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< b = \>", \ b\ ]]; \[IndentingNewLine]P[\([2]\)]\ = \ Rationalize[b[\([1]\)], \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ \((b[\([i]\)]\ - \ b[\([m + 1]\)])\)^\((i - m)\)*\ P[\([m + 1]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For i = \>", \ i, \ "\< and m = \>", \ m, \ "\< term = \>", \ term\ \ ]]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((i\ - \ m)\)\ /\ \((m\ + \ 1)\), \ 0];\[IndentingNewLine], {m, \ 0, \ i - 2, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]P[\([i + 1]\)]\ = \ Rationalize[b[\([i]\)]^i\ - \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< P[[\>", \ i, \ "\<]] stored as P[[\>", \ i + 1, \ "\<]] = \>", \ P[\([i + 1]\)]\ \ ]];\[IndentingNewLine], {i, \ 2, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ P[\([sampleSizePlusOne]\)]; \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["11.1 Steck Sample Intermediate Output", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(SteckKS1SidedRTProbRational[4, \ 10, \ \ 11, \ 2]\)], "Input"], Cell[BoxData[ InterpretationBox[\("SteckKS1SidedRTProbRational: sampleSize = "\ \[InvisibleSpace]11\[InvisibleSpace]" tIn = "\[InvisibleSpace]4\ \[InvisibleSpace]" t = "\[InvisibleSpace]4\[InvisibleSpace]" \ sampleSizePlusOne = "\[InvisibleSpace]12\), SequenceForm[ "SteckKS1SidedRTProbRational: sampleSize = ", 11, " tIn = ", 4, " t = ", 4, " sampleSizePlusOne = ", 12], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" b = "\[InvisibleSpace]{4\/11, 5\/11, 6\/11, 7\/11, 8\/11, 9\/11, 10\/11, 1, 1, 1, 1}\), SequenceForm[ " b = ", { Rational[ 4, 11], Rational[ 5, 11], Rational[ 6, 11], Rational[ 7, 11], Rational[ 8, 11], Rational[ 9, 11], Rational[ 10, 11], 1, 1, 1, 1}], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]24\/121\), SequenceForm[ " P[[", 2, "]] stored as P[[", 3, "]] = ", Rational[ 24, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]196\/1331\), SequenceForm[ " P[[", 3, "]] stored as P[[", 4, "]] = ", Rational[ 196, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]2048\/14641\ \), SequenceForm[ " P[[", 4, "]] stored as P[[", 5, "]] = ", Rational[ 2048, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]6\[InvisibleSpace]"]] = \ "\[InvisibleSpace]26244\/161051\), SequenceForm[ " P[[", 5, "]] stored as P[[", 6, "]] = ", Rational[ 26244, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]7\[InvisibleSpace]"]] = \ "\[InvisibleSpace]400000\/1771561\), SequenceForm[ " P[[", 6, "]] stored as P[[", 7, "]] = ", Rational[ 400000, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]4\/11\), SequenceForm[ " P[[", 7, "]] stored as P[[", 8, "]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]9\[InvisibleSpace]"]] = \ "\[InvisibleSpace]143327232\/214358881\), SequenceForm[ " P[[", 8, "]] stored as P[[", 9, "]] = ", Rational[ 143327232, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]10\[InvisibleSpace]"]] = "\[InvisibleSpace]1972977796\ \/2357947691\), SequenceForm[ " P[[", 9, "]] stored as P[[", 10, "]] = ", Rational[ 1972977796, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]10\[InvisibleSpace]"]] \ stored as P[["\[InvisibleSpace]11\[InvisibleSpace]"]] = \ "\[InvisibleSpace]2166859536\/2357947691\), SequenceForm[ " P[[", 10, "]] stored as P[[", 11, "]] = ", Rational[ 2166859536, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]11\[InvisibleSpace]"]] \ stored as P[["\[InvisibleSpace]12\[InvisibleSpace]"]] = \ "\[InvisibleSpace]273537428212\/285311670611\), SequenceForm[ " P[[", 11, "]] stored as P[[", 12, "]] = ", Rational[ 273537428212, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" rightTailProbability = \ "\[InvisibleSpace]11774242399\/285311670611\), SequenceForm[ " rightTailProbability = ", Rational[ 11774242399, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 12. Conover Recursion Formula with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ ConoverKS1SidedRTProbRational which finds the p-value using the Conover \ recursion formula. Sample intermediate output is given in subsection 12.1.\ \ \>", "Text"], Cell[BoxData[ \(ConoverKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ OneMINUStOVERn, \ OneMINUStOVERnMINUSjOVERn, \ \ rightTailProbability, \ j, \ k, \ e, \ binomialCoefficient, \ term, \ finalNumberTerms, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Conover\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ This\ \ recursion\ formula\ has\ both\ positive\ and\ negative\ \(\(terms\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ W . \ J . \ Conover\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ \ Journal\ of\ the\ American\ Statistical\ Association\ 67, \ \ \((1972)\), \ pp . \ 591 - 596. \ *) \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]finalNumberTerms\ = \ Floor[Rationalize[sampleSize\ - \ t, \ 0]]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< finalNumberTerms = \>", \ finalNumberTerms]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]e\ \ = \ Array[0, \ {sampleSize}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ \ *) \[IndentingNewLine]OneMINUStOVERn\ = \ Rationalize[1\ - \ t/sampleSize, \ 0]; \[IndentingNewLine]e[\([1]\)]\ = \ Rationalize[\ 1\ - \ OneMINUStOVERn, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< OneMINUStOVERn = \>", \ OneMINUStOVERn, \ "\< e[[1]] = \>", \ e[\([1]\)]\ \ \ ]]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ \ = \ Rationalize[OneMINUStOVERn^k, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ = \ OneMINUStOVERn; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For k = \>", \ k, \ "\< and j = 0 binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((k\ - \ j\ + \ 1)\)\ /\ j, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ \ = \ Rationalize[OneMINUStOVERnMINUSjOVERn\ \ - \ 1/sampleSize, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ OneMINUStOVERnMINUSjOVERn\ ^\((k\ - \ j)\)*\ e[\([j]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For k = \>", \ k, \ "\< and j = \>", \ j, \ "\< binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]];\[IndentingNewLine], {j, \ 1, \ k - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]e[\([k]\)]\ = \ Rationalize[1\ - \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< e[[\>", \ k, \ "\<]] = \>", \ e[\([k]\)]\ \ ]];\[IndentingNewLine], {k, \ 2, \ finalNumberTerms, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]term\ = \ Rationalize[OneMINUStOVERn^sampleSize, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ = \ OneMINUStOVERn; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For sampleSize = \>", \ sampleSize, \ "\< and j = 0 binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)\ /\ j, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ \ = \ \ Rationalize[OneMINUStOVERnMINUSjOVERn\ \ - \ 1/sampleSize, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ OneMINUStOVERnMINUSjOVERn\ ^\((sampleSize\ - \ j)\)*\ e[\([j]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For sampleSize = \>", \ sampleSize, \ "\< and j = \>", \ j, \ "\< binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]];\[IndentingNewLine], {j, \ 1, \ finalNumberTerms, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]rightTailProbability\ \ = \ term; \[IndentingNewLine]Label[ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["12.1 Conover Sample Intermediate Output", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(ConoverKS1SidedRTProbRational[4, \ 10, \ \ 11, \ 2]\)], "Input"], Cell[BoxData[ InterpretationBox[\("ConoverKS1SidedRTProbRational: sampleSize = "\ \[InvisibleSpace]11\[InvisibleSpace]" tIn = "\[InvisibleSpace]4\ \[InvisibleSpace]" t = "\[InvisibleSpace]4\[InvisibleSpace]" \ finalNumberTerms = "\[InvisibleSpace]7\), SequenceForm[ "ConoverKS1SidedRTProbRational: sampleSize = ", 11, " tIn = ", 4, " t = ", 4, " finalNumberTerms = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" OneMINUStOVERn = "\[InvisibleSpace]7\/11\ \[InvisibleSpace]" e[[1]] = "\[InvisibleSpace]4\/11\), SequenceForm[ " OneMINUStOVERn = ", Rational[ 7, 11], " e[[1]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]2\[InvisibleSpace]"]] = "\ \[InvisibleSpace]24\/121\), SequenceForm[ " e[[", 2, "]] = ", Rational[ 24, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]3\[InvisibleSpace]"]] = "\ \[InvisibleSpace]196\/1331\), SequenceForm[ " e[[", 3, "]] = ", Rational[ 196, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]4\[InvisibleSpace]"]] = "\ \[InvisibleSpace]2048\/14641\), SequenceForm[ " e[[", 4, "]] = ", Rational[ 2048, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]5\[InvisibleSpace]"]] = "\ \[InvisibleSpace]26244\/161051\), SequenceForm[ " e[[", 5, "]] = ", Rational[ 26244, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]6\[InvisibleSpace]"]] = "\ \[InvisibleSpace]400000\/1771561\), SequenceForm[ " e[[", 6, "]] = ", Rational[ 400000, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" e[["\[InvisibleSpace]7\[InvisibleSpace]"]] = "\ \[InvisibleSpace]4\/11\), SequenceForm[ " e[[", 7, "]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" rightTailProbability = \ "\[InvisibleSpace]11774242399\/285311670611\), SequenceForm[ " rightTailProbability = ", Rational[ 11774242399, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 13. Bolshev Recursion Formula with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ BolshevKS1SidedRTProbRational which finds the p-value using the Bolshev \ recursion formula. Sample intermediate output is given in subsection \ 13.1.\ \>", "Text"], Cell[BoxData[ \(BolshevKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ \ rightTailProbability, \ i, \ j, \ m, \ OneMINUSb, \ P, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Bolshev\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ Formula\ \ used\ to\ implement\ the\ function\ from\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ Shorack\ and\ Wellner\ \((1986)\)\ who\ call\ it\ the\ Bolshev\ \ \(\(recursion\)\(.\)\)\ *) \[IndentingNewLine] (*\ V . \ F . \ Kotelnikov\ and\ E . \ V . \ Chmaladze\[IndentingNewLine]\ \ \ \ \ "\"\ Theory\ of\ Probability\ and\ Its\ \ Application\ 27, \[IndentingNewLine]\ \ \ \ \ \ \((1983)\), \ pp . \ 640 - 648. \ *) \[IndentingNewLine] (*\ G . \ R . \ Shorack\ and\ J . \ A . \ Wellner\[IndentingNewLine]\ \ \ \ \ Empirical\ processes\ with\ \ applications\ to\ statistics, \ \[IndentingNewLine]\ \ \ \ \ \ \(John\ Wiley\ \ &\)\ Sons, \ New\ York\ \(\((1986)\)\(.\)\)\ *) \[IndentingNewLine]sampleSize\ \ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]P\ \ = \ Array[0, \ {sampleSizePlusOne}]; \[IndentingNewLine]OneMINUSb\ = \ Array[0, \ {sampleSize}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]P[\([1]\)]\ \ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]OneMINUSb[\([j]\)]\ \ = \ Rationalize[1\ - \ Min[\((j\ - \ 1\ + \ t)\)/sampleSize, \ 1], \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< OneMINUSb[[\>", \ j, \ "\<]] = \>", \ OneMINUSb[\([j]\)]\ \ ]];\[IndentingNewLine], {j, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< OneMINUSb = \>", \ OneMINUSb\ ]]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ \ Rationalize[0, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[i, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ OneMINUSb[\([i - m + 1]\)]^\((m)\)*\ P[\([i\ - \ m + 1]\)]\ , \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((i\ - \ m)\)\ /\ \((m\ + \ 1)\), \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For i = \>", \ i, \ "\< and m = \>", \ m, \ "\< term = \>", \ term\ \ ]];\[IndentingNewLine], {m, \ 1, \ i, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]P[\([i + 1]\)]\ = \ Rationalize[1\ - \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< P[[\>", \ i, \ "\<]] stored as P[[\>", \ i + 1, \ "\<]] = \>", \ P[\([i + 1]\)]\ \ ]];\[IndentingNewLine], {i, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ P[\([sampleSizePlusOne]\)]; \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell["13.1 Bolshev Sample Intermediate Output", "Subsection"], Cell[BoxData[ InterpretationBox[\("BolshevKS1SidedRTProbRational: sampleSize = "\ \[InvisibleSpace]11\[InvisibleSpace]" tIn = "\[InvisibleSpace]4\ \[InvisibleSpace]" t = "\[InvisibleSpace]4\[InvisibleSpace]" \ sampleSizePlusOne = "\[InvisibleSpace]12\), SequenceForm[ "BolshevKS1SidedRTProbRational: sampleSize = ", 11, " tIn = ", 4, " t = ", 4, " sampleSizePlusOne = ", 12], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" OneMINUSb = "\[InvisibleSpace]{7\/11, 6\/11, 5\/11, 4\/11, 3\/11, 2\/11, 1\/11, 0, 0, 0, 0}\), SequenceForm[ " OneMINUSb = ", { Rational[ 7, 11], Rational[ 6, 11], Rational[ 5, 11], Rational[ 4, 11], Rational[ 3, 11], Rational[ 2, 11], Rational[ 1, 11], 0, 0, 0, 0}], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]1\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]2\[InvisibleSpace]"]] = "\[InvisibleSpace]4\/11\), SequenceForm[ " P[[", 1, "]] stored as P[[", 2, "]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]2\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]3\[InvisibleSpace]"]] = "\[InvisibleSpace]24\/121\), SequenceForm[ " P[[", 2, "]] stored as P[[", 3, "]] = ", Rational[ 24, 121]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]3\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]4\[InvisibleSpace]"]] = "\[InvisibleSpace]196\/1331\), SequenceForm[ " P[[", 3, "]] stored as P[[", 4, "]] = ", Rational[ 196, 1331]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]4\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]5\[InvisibleSpace]"]] = "\[InvisibleSpace]2048\/14641\ \), SequenceForm[ " P[[", 4, "]] stored as P[[", 5, "]] = ", Rational[ 2048, 14641]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]5\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]6\[InvisibleSpace]"]] = \ "\[InvisibleSpace]26244\/161051\), SequenceForm[ " P[[", 5, "]] stored as P[[", 6, "]] = ", Rational[ 26244, 161051]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]6\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]7\[InvisibleSpace]"]] = \ "\[InvisibleSpace]400000\/1771561\), SequenceForm[ " P[[", 6, "]] stored as P[[", 7, "]] = ", Rational[ 400000, 1771561]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]7\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]8\[InvisibleSpace]"]] = "\[InvisibleSpace]4\/11\), SequenceForm[ " P[[", 7, "]] stored as P[[", 8, "]] = ", Rational[ 4, 11]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]8\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]9\[InvisibleSpace]"]] = \ "\[InvisibleSpace]143327232\/214358881\), SequenceForm[ " P[[", 8, "]] stored as P[[", 9, "]] = ", Rational[ 143327232, 214358881]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]9\[InvisibleSpace]"]] stored \ as P[["\[InvisibleSpace]10\[InvisibleSpace]"]] = "\[InvisibleSpace]1972977796\ \/2357947691\), SequenceForm[ " P[[", 9, "]] stored as P[[", 10, "]] = ", Rational[ 1972977796, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]10\[InvisibleSpace]"]] \ stored as P[["\[InvisibleSpace]11\[InvisibleSpace]"]] = \ "\[InvisibleSpace]2166859536\/2357947691\), SequenceForm[ " P[[", 10, "]] stored as P[[", 11, "]] = ", Rational[ 2166859536, 2357947691]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" P[["\[InvisibleSpace]11\[InvisibleSpace]"]] \ stored as P[["\[InvisibleSpace]12\[InvisibleSpace]"]] = \ "\[InvisibleSpace]273537428212\/285311670611\), SequenceForm[ " P[[", 11, "]] stored as P[[", 12, "]] = ", Rational[ 273537428212, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" rightTailProbability = \ "\[InvisibleSpace]11774242399\/285311670611\), SequenceForm[ " rightTailProbability = ", Rational[ 11774242399, 285311670611]], Editable->False]], "Print"], Cell[BoxData[ \(11774242399\/285311670611\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 14. Linear Search DwassAltD Bandwidths with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ KS1SidedBandwidthByLinearSearchDwassAltD which finds the bandwidth using \ linear search and DwassAltD. Sample intermediate output is given in \ subsection 14.1.\ \>", "Text"], Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchDwassAltD[alphaIn_, \ sampleSizeIn_, \ numberDigitsPrecisionIn_, \ intermediateOutput_]\ := \ Module[{alpha, \ sampleSize, \ numberDigitsPrecision, \ dMD, \ rD, \ dLowLimitNumerator, \ dLowLimitDenominator, \ dLowLimitAlpha, \ dHighLimitNumerator, \ dHighLimitDenominator, \ dHighLimitAlpha, \ dNumeratorIncrement, \ numberTries, \ dTryNumerator, \ dTryDenominator, \ dInput, \ alphaOutput, \ dHighLimitMinusLowLimit, \ dNumeratorFinal, \ dDenominatorFinal, \ dFinal}, \[IndentingNewLine] (*\ Calculate\ one - sided\ one\ sample\ KS\ bandwidth\ to\ *) \[IndentingNewLine] (*\ \ \ \ \ numberDigitsPrecisionIn\ significant\ digits\ *) \[IndentingNewLine] \ (*\ \ \ \ for\ sample\ size\ sampleSizeIn\ and\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \(alphaIn\)\(.\)\ \ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]alpha\ = \ Rationalize[alphaIn, \ 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]numberDigitsPrecision\ = \ Floor[numberDigitsPrecisionIn]; \[IndentingNewLine]numberTries\ = \ \ 0; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\", \ "\< \ sampleSize = \>", \ sampleSize, \ "\< alpha = \>", \ alpha, \ "\< = \>", \ N[alpha], "\< numberDigitsPrecision = \>", \ numberDigitsPrecision, "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ inputs\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[alpha\ \[LessEqual] \ 0, \ Print["\", \ alpha, \ "\< is less than or equal to zero.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[GreaterEqual] \ 1, \ Print["\", \ alpha, \ "\< is greater than or equal to one.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ numberDigitsPrecision\ < \ 2, \ Print["\", \ numberDigitsPrecision, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine] (*\ Use\ Maag\ and\ Dicaire\ MD\ approximation\ to\ get\ initial\ value\ \ of\ d, \ dMD\ *) \[IndentingNewLine]dMD\ = N[Sqrt[Log[ alpha]/\((\(-2\)\ *\ sampleSize)\)]\ - \ \((1/\((6* sampleSize)\))\), numberDigitsPrecision]; \[IndentingNewLine]If[dMD\ > \ 1, \ dMD\ = \ 1]; \[IndentingNewLine]If[dMD\ < \ 0, \ dMD\ = \ 0]; \[IndentingNewLine]rD\ = \ RealDigits[dMD]; \[IndentingNewLine] (*\ Using\ dMD, \ create\ the\ first\ guess\ for\ d\ and\ determine\ whether\ it\ is\ \ lower\ or\ higher\ than\ the\ actual\ value\ \ *) \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dMD, sampleSize]; \[IndentingNewLine]numberTries\ = \ 1; \[IndentingNewLine]If[alphaOutput\ > \ alpha, \ Goto[InitialLowLimit], \ Goto[InitialHighLimit]\ ]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ lower\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialLowLimit]; \[IndentingNewLine]dLowLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dLowLimitNumerator\ = \ \ Floor[dMD\ *\ \ dLowLimitDenominator]; \[IndentingNewLine]dLowLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a low limit: dMD = \ \>", \ dMD, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dLowLimit, \ find\ dHighLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dLowLimitDenominator; \[IndentingNewLine]Label[ InitialHighLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dLowLimitNumerator\ + \ dNumeratorIncrement]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[dInput\ \[GreaterEqual] \ 1, \ dHighLimitNumerator\ = \ dLowLimitNumerator; \ dHighLimitDenominator\ = \ dLowLimitNumerator; \ dHighLimitAlpha\ = \ Rationalize[0, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial HighLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[LessEqual] \ alpha, \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dLowLimit\ found\ trying\ to\ find\ initial\ dHighLimit\ \ *) \[IndentingNewLine]dLowLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dLowLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dLowLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial HighLimit a new LowLimit \ was found: dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dLowLimitAlpha = \>", \ \ N[ dLowLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialHighLimitIteration]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ highed\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialHighLimit]; \[IndentingNewLine]dHighLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dHighLimitNumerator\ = \ \ Floor[dMD\ *\ \ dHighLimitDenominator]; \[IndentingNewLine]dHighLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a high limit: dMD = \ \>", \ dMD, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dHighLimit, \ find\ dLowLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dHighLimitDenominator; \[IndentingNewLine]Label[ InitialLowLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dHighLimitNumerator\ - \ dNumeratorIncrement]; \[IndentingNewLine]If[ dTryNumerator\ < \ 10^\((numberDigitsPrecision - 1)\), \ dHighLimitDenominator\ = \ Floor[dHighLimitDenominator*10]; \ \ dHighLimitNumerator\ = \ Floor[dHighLimitNumerator*10]; \ \ dTryDenominator\ = \ Floor[dTryDenominator*10]; \ \ \ \ dTryNumerator\ = \ Floor[dTryNumerator*10]; \ dNumeratorIncrement\ = \ Floor[dNumeratorIncrement*10]\ \ ]; \[IndentingNewLine]dInput\ = \ \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[ dInput\ \[LessEqual] \ 0, \ dLowLimitNumerator\ = \ dHighLimitNumerator; \ dLowLimitDenominator\ = \ dHighLimitNumerator; \ dLowLimitAlpha\ = \ Rationalize[1, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial LowLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[GreaterEqual] \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dHighLimit\ found\ trying\ to\ find\ initial\ dLowLimit\ \ *) \[IndentingNewLine]dHighLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dHighLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dHighLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial LowLimit a new HighLimit \ was found: dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator, \ "\< dHighLimitAlpha = \>", \ \ N[ dHighLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialLowLimitIteration]; \[IndentingNewLine] (*\ Initial\ dLowLimit\ and\ dHighLimit\ found\ \ *) \[IndentingNewLine]Label[ InitialLowAndHighLimitsFound]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Initial Low and High Limits found: \ dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Begin\ search\ between\ dLowLimit\ and\ dHighLimit\ \ *) \[IndentingNewLine]Label[ SearchIteration]; \[IndentingNewLine]dHighLimitMinusLowLimit\ = \ Floor[dHighLimitNumerator\ - \ dLowLimitNumerator]; \[IndentingNewLine]If[ dHighLimitMinusLowLimit\ \[LessEqual] \ 1, \ Goto[dFinalDetermination]\ ]; \[IndentingNewLine]dTryDenominator\ \ = \ dHighLimitDenominator; \[IndentingNewLine]dTryNumerator\ = \ Floor[Rationalize[ dLowLimitNumerator\ + \ dHighLimitMinusLowLimit*\((dLowLimitAlpha\ - \ alpha)\)/\((dLowLimitAlpha\ - \ dHighLimitAlpha)\), \ 0]]; \[IndentingNewLine]If[ dTryNumerator\ \[GreaterEqual] \ dHighLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ - \ 1]\ ]; \[IndentingNewLine]If[ dTryNumerator \[LessEqual] \ dLowLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ + \ 1]\ ]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Search: dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha]]]; \[IndentingNewLine]If[ alphaOutput\ > \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput;\ , \ \ \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput;]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ If[alphaOutput\ > \ alpha, \ Print["\< New search above is a new LowLimit\>"], \ Print["\< New search above is a new HighLimit\>"]\ ]\ ]; \ \[IndentingNewLine]Goto[SearchIteration]; \[IndentingNewLine] (*\ Determine\ whether\ LowLimit\ or\ HighLimit\ is\ dFinal\ \ *) \[IndentingNewLine]Label[dFinalDetermination]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Low and High Limits found: dLowLimitNumerator = \>", \ \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator]]; \[IndentingNewLine]dTryDenominator\ = \ Floor[dLowLimitDenominator\ *\ 10]; \[IndentingNewLine]dTryNumerator\ = \ Floor[dLowLimitNumerator\ *\ 10\ + \ 5]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Determine whether LowLimit or HighLimit is dFinal: \ dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ < \ alpha, \ \ dNumeratorFinal\ = \ dLowLimitNumerator; \ dDenominatorFinal\ = \ dLowLimitDenominator;\ \ , \ dNumeratorFinal\ = \ dHighLimitNumerator; \ dDenominatorFinal\ = \ dHighLimitDenominator;\ \ ]; \[IndentingNewLine]dFinal\ = \ Rationalize[\ dNumeratorFinal/dDenominatorFinal, \ 0]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\< dFinal found: dNumeratorFinal = \>", \ dNumeratorFinal, \ "\< dDenominatorFinal = \>", \ dDenominatorFinal\ , \ "\< dFinal = \>", \ dFinal, \ "\< = \>", \ N[dFinal, \ numberDigitsPrecision], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]{N[dFinal, \ numberDigitsPrecision], \ numberTries}\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(DwassAltDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Dwass\ Alternate\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ \ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ d]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[sampleSize\ + \ d\ *\ sampleSize, \ 0]; \[IndentingNewLine]thirdTerm\ = \ \(-d\)\ *\ sampleSize; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ 1\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ 1\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j\ - \ 1)\)\ *\ thirdTerm^j)\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[ 1\ - \ \((d\ *\ sumTerms/sampleSize^\((sampleSize\ - \ 1)\))\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ 14.1 Linear Search DwassAltD Bandwidths Sample Intermediate Output\ \>", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchDwassAltD[0.25, \ 50, \ 10, \ 3]\)], "Input"], Cell[BoxData[ InterpretationBox[\("KS1SidedBandwidthByLinearSearchDwassAltD:"\ \[InvisibleSpace]" sampleSize = "\[InvisibleSpace]50\[InvisibleSpace]" \ alpha = "\[InvisibleSpace]1\/4\[InvisibleSpace]" = "\[InvisibleSpace]0.25`\ \[InvisibleSpace]" numberDigitsPrecision = "\[InvisibleSpace]10\ \[InvisibleSpace]" numberTries = "\[InvisibleSpace]0\), SequenceForm[ "KS1SidedBandwidthByLinearSearchDwassAltD:", " sampleSize = ", 50, " alpha = ", Rational[ 1, 4], " = ", .25, " numberDigitsPrecision = ", 10, " numberTries = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Maag and Dicaire approximation is a low limit: \ dMD = "\[InvisibleSpace]0.1144076689182141357664946908`10. \[InvisibleSpace]" \ dLowLimitNumerator = "\[InvisibleSpace]1144076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2507521869671434`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries \ = "\[InvisibleSpace]1\), SequenceForm[ " Maag and Dicaire approximation is a low limit: dMD = ", 0.1144076689182141357664946908`10., " dLowLimitNumerator = ", 1144076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25075218696714341, " is greater than alpha = ", .25, " numberTries = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]1000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]2\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 1000000, " dTryNumerator = ", 1145076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145076689`10., " alphaOutput = ", .25016119688080912, " numberTries = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" In trying to find the initial HighLimit a new \ LowLimit was found: dLowLimitNumerator = "\[InvisibleSpace]1145076689\ \[InvisibleSpace]" dLowLimitDenominator = "\[InvisibleSpace]10000000000\ \[InvisibleSpace]" dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\), SequenceForm[ " In trying to find the initial HighLimit a new LowLimit was found: \ dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]10000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1155076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 10000000, " dTryNumerator = ", 1155076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1155076689`10., " alphaOutput = ", .24430010508896607, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Initial Low and High Limits found: \ dLowLimitNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" \ dHighLimitNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dHighLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dHighLimitAlpha = "\[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" is \ less than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Initial Low and High Limits found: dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912, " is greater than alpha = ", .25, " dHighLimitNumerator = ", 1155076689, " dHighLimitDenominator = ", 10000000000, " dHighLimitAlpha = ", .24430010508896607, " is less than alpha = ", .25, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145351717\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145351717`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24999881348012207`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]4\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1155076689\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24430010508896607`\), SequenceForm[ " Search: dTryNumerator = ", 1145351717, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145351717`10., " alphaOutput = ", .24999881348012207, " numberTries = ", 4, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1155076689, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24430010508896607], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349707\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]5\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145351717\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24999881348012207`\), SequenceForm[ " Search: dTryNumerator = ", 1145349707, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349707`10., " alphaOutput = ", .249999999991038, " numberTries = ", 5, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145351717, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24999881348012207], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349706`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]6\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\), SequenceForm[ " Search: dTryNumerator = ", 1145349706, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349706`10., " alphaOutput = ", .25000000058134286, " numberTries = ", 6, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .249999999991038], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new LowLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Low and High Limits found: dLowLimitNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" dLowLimitDenominator \ = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dHighLimitDenominator = "\ \[InvisibleSpace]10000000000\), SequenceForm[ " Low and High Limits found: dLowLimitNumerator = ", 1145349706, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25000000058134286, " dHighLimitAlpha = ", .249999999991038, " dLowLimitDenominator = ", 10000000000, " dHighLimitDenominator = ", 10000000000], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Determine whether LowLimit or HighLimit is \ dFinal: dTryNumerator = "\[InvisibleSpace]11453497065\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]100000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.11453497065`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2500000002861904`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " Determine whether LowLimit or HighLimit is dFinal: dTryNumerator \ = ", 11453497065, " dTryDenominator = ", 100000000000, " dInput = ", 0.11453497065`10., " alphaOutput = ", .2500000002861904, " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" dFinal found: dNumeratorFinal = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dDenominatorFinal = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dFinal = \ "\[InvisibleSpace]1145349707\/10000000000\[InvisibleSpace]" = "\ \[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " dFinal found: dNumeratorFinal = ", 1145349707, " dDenominatorFinal = ", 10000000000, " dFinal = ", Rational[ 1145349707, 10000000000], " = ", 0.1145349707`10., " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ \({0.1145349707`10. , 7}\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell["\<\ 15. Linear Search DwassD Bandwidths with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ KS1SidedBandwidthByLinearSearchDwassD which finds the bandwidth using linear \ search and DwassD. Sample intermediate output is given in subsection \ 15.1.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchDwassD[alphaIn_, \ sampleSizeIn_, \ numberDigitsPrecisionIn_, \ intermediateOutput_]\ := \ Module[{alpha, \ sampleSize, \ numberDigitsPrecision, \ dMD, \ rD, \ dLowLimitNumerator, \ dLowLimitDenominator, \ dLowLimitAlpha, \ dHighLimitNumerator, \ dHighLimitDenominator, \ dHighLimitAlpha, \ dNumeratorIncrement, \ numberTries, \ dTryNumerator, \ dTryDenominator, \ dInput, \ alphaOutput, \ dHighLimitMinusLowLimit, \ dNumeratorFinal, \ dDenominatorFinal, \ dFinal}, \[IndentingNewLine] (*\ Calculate\ one - sided\ one\ sample\ KS\ bandwidth\ to\ *) \[IndentingNewLine] (*\ \ \ \ \ numberDigitsPrecisionIn\ significant\ digits\ *) \[IndentingNewLine] \ (*\ \ \ \ for\ sample\ size\ sampleSizeIn\ and\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \(alphaIn\)\(.\)\ \ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]alpha\ = \ Rationalize[alphaIn, \ 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]numberDigitsPrecision\ = \ Floor[numberDigitsPrecisionIn]; \[IndentingNewLine]numberTries\ = \ \ 0; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\", \ "\< \ sampleSize = \>", \ sampleSize, \ "\< alpha = \>", \ alpha, \ "\< = \>", \ N[alpha], "\< numberDigitsPrecision = \>", \ numberDigitsPrecision, "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ inputs\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[alpha\ \[LessEqual] \ 0, \ Print["\", \ \ alpha, \ "\< is less than or equal to zero.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[GreaterEqual] \ 1, \ Print["\", \ \ alpha, \ "\< is greater than or equal to one.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ numberDigitsPrecision\ < \ 2, \ Print["\", \ numberDigitsPrecision, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine] (*\ Use\ Maag\ and\ Dicaire\ MD\ approximation\ to\ get\ initial\ value\ \ of\ d, \ dMD\ *) \[IndentingNewLine]dMD\ = N[Sqrt[Log[ alpha]/\((\(-2\)\ *\ sampleSize)\)]\ - \ \((1/\((6* sampleSize)\))\), numberDigitsPrecision]; \[IndentingNewLine]If[dMD\ > \ 1, \ dMD\ = \ 1]; \[IndentingNewLine]If[dMD\ < \ 0, \ dMD\ = \ 0]; \[IndentingNewLine]rD\ = \ RealDigits[dMD]; \[IndentingNewLine] (*\ Using\ dMD, \ create\ the\ first\ guess\ for\ d\ and\ determine\ whether\ it\ is\ \ lower\ or\ higher\ than\ the\ actual\ value\ \ *) \[IndentingNewLine]alphaOutput\ = \ DwassDKS1SidedRTRational[dMD, sampleSize]; \[IndentingNewLine]numberTries\ = \ 1; \[IndentingNewLine]If[alphaOutput\ > \ alpha, \ Goto[InitialLowLimit], \ Goto[InitialHighLimit]\ ]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ lower\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialLowLimit]; \[IndentingNewLine]dLowLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dLowLimitNumerator\ = \ \ Floor[dMD\ *\ \ dLowLimitDenominator]; \[IndentingNewLine]dLowLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a low limit: dMD = \ \>", \ dMD, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dLowLimit, \ find\ dHighLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dLowLimitDenominator; \[IndentingNewLine]Label[ InitialHighLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dLowLimitNumerator\ + \ dNumeratorIncrement]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[dInput\ \[GreaterEqual] \ 1, \ dHighLimitNumerator\ = \ dLowLimitNumerator; \ dHighLimitDenominator\ = \ dLowLimitNumerator; \ dHighLimitAlpha\ = \ Rationalize[0, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial HighLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[LessEqual] \ alpha, \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dLowLimit\ found\ trying\ to\ find\ initial\ dHighLimit\ \ *) \[IndentingNewLine]dLowLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dLowLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dLowLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial HighLimit a new LowLimit \ was found: dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dLowLimitAlpha = \>", \ \ N[ dLowLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialHighLimitIteration]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ highed\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialHighLimit]; \[IndentingNewLine]dHighLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dHighLimitNumerator\ = \ \ Floor[dMD\ *\ \ dHighLimitDenominator]; \[IndentingNewLine]dHighLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a high limit: dMD = \ \>", \ dMD, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dHighLimit, \ find\ dLowLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dHighLimitDenominator; \[IndentingNewLine]Label[ InitialLowLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dHighLimitNumerator\ - \ dNumeratorIncrement]; \[IndentingNewLine]If[ dTryNumerator\ < \ 10^\((numberDigitsPrecision - 1)\), \ dHighLimitDenominator\ = \ Floor[dHighLimitDenominator*10]; \ \ dHighLimitNumerator\ = \ Floor[dHighLimitNumerator*10]; \ \ dTryDenominator\ = \ Floor[dTryDenominator*10]; \ \ \ \ dTryNumerator\ = \ Floor[dTryNumerator*10]; \ dNumeratorIncrement\ = \ Floor[dNumeratorIncrement*10]\ \ ]; \[IndentingNewLine]dInput\ = \ \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[ dInput\ \[LessEqual] \ 0, \ dLowLimitNumerator\ = \ dHighLimitNumerator; \ dLowLimitDenominator\ = \ dHighLimitNumerator; \ dLowLimitAlpha\ = \ Rationalize[1, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial LowLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[GreaterEqual] \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dHighLimit\ found\ trying\ to\ find\ initial\ dLowLimit\ \ *) \[IndentingNewLine]dHighLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dHighLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dHighLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial LowLimit a new HighLimit \ was found: dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator, \ "\< dHighLimitAlpha = \>", \ \ N[ dHighLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialLowLimitIteration]; \[IndentingNewLine] (*\ Initial\ dLowLimit\ and\ dHighLimit\ found\ \ *) \[IndentingNewLine]Label[ InitialLowAndHighLimitsFound]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Initial Low and High Limits found: \ dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Begin\ search\ between\ dLowLimit\ and\ dHighLimit\ \ *) \[IndentingNewLine]Label[ SearchIteration]; \[IndentingNewLine]dHighLimitMinusLowLimit\ = \ Floor[dHighLimitNumerator\ - \ dLowLimitNumerator]; \[IndentingNewLine]If[ dHighLimitMinusLowLimit\ \[LessEqual] \ 1, \ Goto[dFinalDetermination]\ ]; \[IndentingNewLine]dTryDenominator\ \ = \ dHighLimitDenominator; \[IndentingNewLine]dTryNumerator\ = \ Floor[Rationalize[ dLowLimitNumerator\ + \ dHighLimitMinusLowLimit*\((dLowLimitAlpha\ - \ alpha)\)/\((dLowLimitAlpha\ - \ dHighLimitAlpha)\), \ 0]]; \[IndentingNewLine]If[ dTryNumerator\ \[GreaterEqual] \ dHighLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ - \ 1]\ ]; \[IndentingNewLine]If[ dTryNumerator \[LessEqual] \ dLowLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ + \ 1]\ ]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Search: dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha]]]; \[IndentingNewLine]If[ alphaOutput\ > \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput;\ , \ \ \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput;]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ If[alphaOutput\ > \ alpha, \ Print["\< New search above is a new LowLimit\>"], \ Print["\< New search above is a new HighLimit\>"]\ ]\ ]; \ \[IndentingNewLine]Goto[SearchIteration]; \[IndentingNewLine] (*\ Determine\ whether\ LowLimit\ or\ HighLimit\ is\ dFinal\ \ *) \[IndentingNewLine]Label[dFinalDetermination]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Low and High Limits found: dLowLimitNumerator = \>", \ \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator]]; \[IndentingNewLine]dTryDenominator\ = \ Floor[dLowLimitDenominator\ *\ 10]; \[IndentingNewLine]dTryNumerator\ = \ Floor[dLowLimitNumerator\ *\ 10\ + \ 5]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Determine whether LowLimit or HighLimit is dFinal: \ dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ < \ alpha, \ \ dNumeratorFinal\ = \ dLowLimitNumerator; \ dDenominatorFinal\ = \ dLowLimitDenominator;\ \ , \ dNumeratorFinal\ = \ dHighLimitNumerator; \ dDenominatorFinal\ = \ dHighLimitDenominator;\ \ ]; \[IndentingNewLine]dFinal\ = \ Rationalize[\ dNumeratorFinal/dDenominatorFinal, \ 0]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\< dFinal found: dNumeratorFinal = \>", \ dNumeratorFinal, \ "\< dDenominatorFinal = \>", \ dDenominatorFinal\ , \ "\< dFinal = \>", \ dFinal, \ "\< = \>", \ N[dFinal, \ numberDigitsPrecision], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]{N[dFinal, \ numberDigitsPrecision], \ numberTries}\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(DwassDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Dwass\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ d]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[1\ + \ d, \ 0]; \[IndentingNewLine]thirdTerm\ = \ \(-d\); \ \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j\ - \ 1)\)\ *\ thirdTerm^j)\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[1\ - \ \((d\ *\ sumTerms)\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ 15.1 Linear Search DwassD Bandwidths Sample Intermediate Output\ \>", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchDwassD[0.25, \ 50, \ 10, \ 3]\)], "Input"], Cell[BoxData[ InterpretationBox[\("KS1SidedBandwidthByLinearSearchDwassD:"\ \[InvisibleSpace]" sampleSize = "\[InvisibleSpace]50\[InvisibleSpace]" \ alpha = "\[InvisibleSpace]1\/4\[InvisibleSpace]" = "\[InvisibleSpace]0.25`\ \[InvisibleSpace]" numberDigitsPrecision = "\[InvisibleSpace]10\ \[InvisibleSpace]" numberTries = "\[InvisibleSpace]0\), SequenceForm[ "KS1SidedBandwidthByLinearSearchDwassD:", " sampleSize = ", 50, " alpha = ", Rational[ 1, 4], " = ", .25, " numberDigitsPrecision = ", 10, " numberTries = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Maag and Dicaire approximation is a low limit: \ dMD = "\[InvisibleSpace]0.1144076689182141357664946908`10. \[InvisibleSpace]" \ dLowLimitNumerator = "\[InvisibleSpace]1144076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2507521869671434`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries \ = "\[InvisibleSpace]1\), SequenceForm[ " Maag and Dicaire approximation is a low limit: dMD = ", 0.1144076689182141357664946908`10., " dLowLimitNumerator = ", 1144076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25075218696714341, " is greater than alpha = ", .25, " numberTries = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]1000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]2\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 1000000, " dTryNumerator = ", 1145076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145076689`10., " alphaOutput = ", .25016119688080912, " numberTries = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" In trying to find the initial HighLimit a new \ LowLimit was found: dLowLimitNumerator = "\[InvisibleSpace]1145076689\ \[InvisibleSpace]" dLowLimitDenominator = "\[InvisibleSpace]10000000000\ \[InvisibleSpace]" dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\), SequenceForm[ " In trying to find the initial HighLimit a new LowLimit was found: \ dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]10000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1155076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 10000000, " dTryNumerator = ", 1155076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1155076689`10., " alphaOutput = ", .24430010508896607, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Initial Low and High Limits found: \ dLowLimitNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" \ dHighLimitNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dHighLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dHighLimitAlpha = "\[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" is \ less than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Initial Low and High Limits found: dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912, " is greater than alpha = ", .25, " dHighLimitNumerator = ", 1155076689, " dHighLimitDenominator = ", 10000000000, " dHighLimitAlpha = ", .24430010508896607, " is less than alpha = ", .25, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145351717\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145351717`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24999881348012207`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]4\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1155076689\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24430010508896607`\), SequenceForm[ " Search: dTryNumerator = ", 1145351717, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145351717`10., " alphaOutput = ", .24999881348012207, " numberTries = ", 4, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1155076689, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24430010508896607], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349707\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]5\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145351717\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24999881348012207`\), SequenceForm[ " Search: dTryNumerator = ", 1145349707, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349707`10., " alphaOutput = ", .249999999991038, " numberTries = ", 5, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145351717, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24999881348012207], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349706`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]6\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\), SequenceForm[ " Search: dTryNumerator = ", 1145349706, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349706`10., " alphaOutput = ", .25000000058134286, " numberTries = ", 6, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .249999999991038], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new LowLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Low and High Limits found: dLowLimitNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" dLowLimitDenominator \ = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dHighLimitDenominator = "\ \[InvisibleSpace]10000000000\), SequenceForm[ " Low and High Limits found: dLowLimitNumerator = ", 1145349706, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25000000058134286, " dHighLimitAlpha = ", .249999999991038, " dLowLimitDenominator = ", 10000000000, " dHighLimitDenominator = ", 10000000000], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Determine whether LowLimit or HighLimit is \ dFinal: dTryNumerator = "\[InvisibleSpace]11453497065\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]100000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.11453497065`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2500000002861904`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " Determine whether LowLimit or HighLimit is dFinal: dTryNumerator \ = ", 11453497065, " dTryDenominator = ", 100000000000, " dInput = ", 0.11453497065`10., " alphaOutput = ", .2500000002861904, " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" dFinal found: dNumeratorFinal = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dDenominatorFinal = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dFinal = \ "\[InvisibleSpace]1145349707\/10000000000\[InvisibleSpace]" = "\ \[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " dFinal found: dNumeratorFinal = ", 1145349707, " dDenominatorFinal = ", 10000000000, " dFinal = ", Rational[ 1145349707, 10000000000], " = ", 0.1145349707`10., " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ \({0.1145349707`10. , 7}\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 16. Linear Search SmirnovAltD Bandwidths with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ KS1SidedBandwidthByLinearSearchSmirnovAltD which finds the bandwidth using \ linear search and SmirnovAltD. Sample intermediate output is given in \ subsection 16.1.\ \>", "Text"], Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchSmirnovAltD[alphaIn_, \ sampleSizeIn_, \ numberDigitsPrecisionIn_, \ intermediateOutput_]\ := \ Module[{alpha, \ sampleSize, \ numberDigitsPrecision, \ dMD, \ rD, \ dLowLimitNumerator, \ dLowLimitDenominator, \ dLowLimitAlpha, \ dHighLimitNumerator, \ dHighLimitDenominator, \ dHighLimitAlpha, \ dNumeratorIncrement, \ numberTries, \ dTryNumerator, \ dTryDenominator, \ dInput, \ alphaOutput, \ dHighLimitMinusLowLimit, \ dNumeratorFinal, \ dDenominatorFinal, \ dFinal}, \[IndentingNewLine] (*\ Calculate\ one - sided\ one\ sample\ KS\ bandwidth\ to\ *) \[IndentingNewLine] (*\ \ \ \ \ numberDigitsPrecisionIn\ significant\ digits\ *) \[IndentingNewLine] \ (*\ \ \ \ for\ sample\ size\ sampleSizeIn\ and\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \(alphaIn\)\(.\)\ \ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]alpha\ = \ Rationalize[alphaIn, \ 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]numberDigitsPrecision\ = \ Floor[numberDigitsPrecisionIn]; \[IndentingNewLine]numberTries\ = \ \ 0; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\", \ "\< \ sampleSize = \>", \ sampleSize, \ "\< alpha = \>", \ alpha, \ "\< = \>", \ N[alpha], "\< numberDigitsPrecision = \>", \ numberDigitsPrecision, "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ inputs\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[LessEqual] \ 0, \ Print["\", \ alpha, \ "\< is less than or equal to zero.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[GreaterEqual] \ 1, \ Print["\", \ alpha, \ "\< is greater than or equal to one.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ numberDigitsPrecision\ < \ 2, \ Print["\", \ numberDigitsPrecision, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine] (*\ Use\ Maag\ and\ Dicaire\ MD\ approximation\ to\ get\ initial\ value\ \ of\ d, \ dMD\ *) \[IndentingNewLine]dMD\ = N[Sqrt[Log[ alpha]/\((\(-2\)\ *\ sampleSize)\)]\ - \ \((1/\((6* sampleSize)\))\), numberDigitsPrecision]; \[IndentingNewLine]If[dMD\ > \ 1, \ dMD\ = \ 1]; \[IndentingNewLine]If[dMD\ < \ 0, \ dMD\ = \ 0]; \[IndentingNewLine]rD\ = \ RealDigits[dMD]; \[IndentingNewLine] (*\ Using\ dMD, \ create\ the\ first\ guess\ for\ d\ and\ determine\ whether\ it\ is\ \ lower\ or\ higher\ than\ the\ actual\ value\ \ *) \[IndentingNewLine]alphaOutput\ = \ SmirnovAltDKS1SidedRTRational[dMD, sampleSize]; \[IndentingNewLine]numberTries\ = \ 1; \[IndentingNewLine]If[alphaOutput\ > \ alpha, \ Goto[InitialLowLimit], \ Goto[InitialHighLimit]\ ]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ lower\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialLowLimit]; \[IndentingNewLine]dLowLimitDenominator\ = \ Floor[ 10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dLowLimitNumerator\ = \ \ Floor[dMD\ *\ \ dLowLimitDenominator]; \[IndentingNewLine]dLowLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a low limit: dMD = \ \>", \ dMD, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dLowLimit, \ find\ dHighLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dLowLimitDenominator; \[IndentingNewLine]Label[ InitialHighLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dLowLimitNumerator\ + \ dNumeratorIncrement]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[dInput\ \[GreaterEqual] \ 1, \ dHighLimitNumerator\ = \ dLowLimitNumerator; \ dHighLimitDenominator\ = \ dLowLimitNumerator; \ dHighLimitAlpha\ = \ Rationalize[0, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ SmirnovAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial HighLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[LessEqual] \ alpha, \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dLowLimit\ found\ trying\ to\ find\ initial\ dHighLimit\ \ *) \[IndentingNewLine]dLowLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dLowLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dLowLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial HighLimit a new LowLimit \ was found: dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dLowLimitAlpha = \>", \ \ N[ dLowLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialHighLimitIteration]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ highed\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialHighLimit]; \[IndentingNewLine]dHighLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dHighLimitNumerator\ = \ \ Floor[dMD\ *\ \ dHighLimitDenominator]; \[IndentingNewLine]dHighLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a high limit: dMD = \ \>", \ dMD, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dHighLimit, \ find\ dLowLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dHighLimitDenominator; \[IndentingNewLine]Label[ InitialLowLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dHighLimitNumerator\ - \ dNumeratorIncrement]; \[IndentingNewLine]If[ dTryNumerator\ < \ 10^\((numberDigitsPrecision - 1)\), \ dHighLimitDenominator\ = \ Floor[dHighLimitDenominator*10]; \ \ dHighLimitNumerator\ = \ Floor[dHighLimitNumerator*10]; \ \ dTryDenominator\ = \ Floor[dTryDenominator*10]; \ \ \ \ dTryNumerator\ = \ Floor[dTryNumerator*10]; \ dNumeratorIncrement\ = \ Floor[dNumeratorIncrement*10]\ \ ]; \[IndentingNewLine]dInput\ = \ \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[ dInput\ \[LessEqual] \ 0, \ dLowLimitNumerator\ = \ dHighLimitNumerator; \ dLowLimitDenominator\ = \ dHighLimitNumerator; \ dLowLimitAlpha\ = \ Rationalize[1, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ SmirnovAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial LowLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[GreaterEqual] \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dHighLimit\ found\ trying\ to\ find\ initial\ dLowLimit\ \ *) \[IndentingNewLine]dHighLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dHighLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dHighLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial LowLimit a new HighLimit \ was found: dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator, \ "\< dHighLimitAlpha = \>", \ \ N[ dHighLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialLowLimitIteration]; \[IndentingNewLine] (*\ Initial\ dLowLimit\ and\ dHighLimit\ found\ \ *) \[IndentingNewLine]Label[ InitialLowAndHighLimitsFound]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Initial Low and High Limits found: \ dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Begin\ search\ between\ dLowLimit\ and\ dHighLimit\ \ *) \[IndentingNewLine]Label[ SearchIteration]; \[IndentingNewLine]dHighLimitMinusLowLimit\ = \ Floor[dHighLimitNumerator\ - \ dLowLimitNumerator]; \[IndentingNewLine]If[ dHighLimitMinusLowLimit\ \[LessEqual] \ 1, \ Goto[dFinalDetermination]\ ]; \[IndentingNewLine]dTryDenominator\ \ = \ dHighLimitDenominator; \[IndentingNewLine]dTryNumerator\ = \ Floor[Rationalize[ dLowLimitNumerator\ + \ dHighLimitMinusLowLimit*\((dLowLimitAlpha\ - \ alpha)\)/\((dLowLimitAlpha\ - \ dHighLimitAlpha)\), \ 0]]; \[IndentingNewLine]If[ dTryNumerator\ \[GreaterEqual] \ dHighLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ - \ 1]\ ]; \[IndentingNewLine]If[ dTryNumerator \[LessEqual] \ dLowLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ + \ 1]\ ]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ SmirnovAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Search: dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha]]]; \[IndentingNewLine]If[ alphaOutput\ > \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput;\ , \ \ \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput;]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ If[alphaOutput\ > \ alpha, \ Print["\< New search above is a new LowLimit\>"], \ Print["\< New search above is a new HighLimit\>"]\ ]\ ]; \ \[IndentingNewLine]Goto[SearchIteration]; \[IndentingNewLine] (*\ Determine\ whether\ LowLimit\ or\ HighLimit\ is\ dFinal\ \ *) \[IndentingNewLine]Label[dFinalDetermination]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Low and High Limits found: dLowLimitNumerator = \>", \ \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator]]; \[IndentingNewLine]dTryDenominator\ = \ Floor[dLowLimitDenominator\ *\ 10]; \[IndentingNewLine]dTryNumerator\ = \ Floor[dLowLimitNumerator\ *\ 10\ + \ 5]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ SmirnovAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Determine whether LowLimit or HighLimit is dFinal: \ dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ < \ alpha, \ \ dNumeratorFinal\ = \ dLowLimitNumerator; \ dDenominatorFinal\ = \ dLowLimitDenominator;\ \ , \ dNumeratorFinal\ = \ dHighLimitNumerator; \ dDenominatorFinal\ = \ dHighLimitDenominator;\ \ ]; \[IndentingNewLine]dFinal\ = \ Rationalize[\ dNumeratorFinal/dDenominatorFinal, \ 0]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\< dFinal found: dNumeratorFinal = \>", \ dNumeratorFinal, \ "\< dDenominatorFinal = \>", \ dDenominatorFinal\ , \ "\< dFinal = \>", \ dFinal, \ "\< = \>", \ N[dFinal, \ numberDigitsPrecision], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]{N[dFinal, \ numberDigitsPrecision], \ numberTries}\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(SmirnovAltDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Smirnov\ Alternate\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1941)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[sampleSize\ *\ \((1\ - \ d)\), \ 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[sampleSize\ *\ d, \ 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^sampleSize/thirdTerm, \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ 1\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ 1\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j)\)\ *\ thirdTerm^\((j\ - \ 1)\))\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[ d\ *\ sumTerms*\ sampleSize^\((\(-\ sampleSize\)\ + \ 1)\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ 16.1 Linear Search SmirnovAltD Bandwidths Sample Intermediate Output\ \>", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchSmirnovAltD[0.25, \ 50, \ 10, \ 3]\)], "Input"], Cell[BoxData[ InterpretationBox[\("KS1SidedBandwidthByLinearSearchSmirnovAltD:"\ \[InvisibleSpace]" sampleSize = "\[InvisibleSpace]50\[InvisibleSpace]" \ alpha = "\[InvisibleSpace]1\/4\[InvisibleSpace]" = "\[InvisibleSpace]0.25`\ \[InvisibleSpace]" numberDigitsPrecision = "\[InvisibleSpace]10\ \[InvisibleSpace]" numberTries = "\[InvisibleSpace]0\), SequenceForm[ "KS1SidedBandwidthByLinearSearchSmirnovAltD:", " sampleSize = ", 50, " alpha = ", Rational[ 1, 4], " = ", .25, " numberDigitsPrecision = ", 10, " numberTries = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Maag and Dicaire approximation is a low limit: \ dMD = "\[InvisibleSpace]0.1144076689182141357664946908`10. \[InvisibleSpace]" \ dLowLimitNumerator = "\[InvisibleSpace]1144076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2507521869671434`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries \ = "\[InvisibleSpace]1\), SequenceForm[ " Maag and Dicaire approximation is a low limit: dMD = ", 0.1144076689182141357664946908`10., " dLowLimitNumerator = ", 1144076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25075218696714341, " is greater than alpha = ", .25, " numberTries = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]1000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]2\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 1000000, " dTryNumerator = ", 1145076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145076689`10., " alphaOutput = ", .25016119688080912, " numberTries = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" In trying to find the initial HighLimit a new \ LowLimit was found: dLowLimitNumerator = "\[InvisibleSpace]1145076689\ \[InvisibleSpace]" dLowLimitDenominator = "\[InvisibleSpace]10000000000\ \[InvisibleSpace]" dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\), SequenceForm[ " In trying to find the initial HighLimit a new LowLimit was found: \ dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]10000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1155076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 10000000, " dTryNumerator = ", 1155076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1155076689`10., " alphaOutput = ", .24430010508896607, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Initial Low and High Limits found: \ dLowLimitNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" \ dHighLimitNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dHighLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dHighLimitAlpha = "\[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" is \ less than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Initial Low and High Limits found: dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912, " is greater than alpha = ", .25, " dHighLimitNumerator = ", 1155076689, " dHighLimitDenominator = ", 10000000000, " dHighLimitAlpha = ", .24430010508896607, " is less than alpha = ", .25, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145351717\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145351717`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24999881348012207`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]4\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1155076689\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24430010508896607`\), SequenceForm[ " Search: dTryNumerator = ", 1145351717, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145351717`10., " alphaOutput = ", .24999881348012207, " numberTries = ", 4, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1155076689, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24430010508896607], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349707\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]5\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145351717\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24999881348012207`\), SequenceForm[ " Search: dTryNumerator = ", 1145349707, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349707`10., " alphaOutput = ", .249999999991038, " numberTries = ", 5, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145351717, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24999881348012207], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349706`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]6\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\), SequenceForm[ " Search: dTryNumerator = ", 1145349706, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349706`10., " alphaOutput = ", .25000000058134286, " numberTries = ", 6, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .249999999991038], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new LowLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Low and High Limits found: dLowLimitNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" dLowLimitDenominator \ = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dHighLimitDenominator = "\ \[InvisibleSpace]10000000000\), SequenceForm[ " Low and High Limits found: dLowLimitNumerator = ", 1145349706, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25000000058134286, " dHighLimitAlpha = ", .249999999991038, " dLowLimitDenominator = ", 10000000000, " dHighLimitDenominator = ", 10000000000], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Determine whether LowLimit or HighLimit is \ dFinal: dTryNumerator = "\[InvisibleSpace]11453497065\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]100000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.11453497065`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2500000002861904`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " Determine whether LowLimit or HighLimit is dFinal: dTryNumerator \ = ", 11453497065, " dTryDenominator = ", 100000000000, " dInput = ", 0.11453497065`10., " alphaOutput = ", .2500000002861904, " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" dFinal found: dNumeratorFinal = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dDenominatorFinal = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dFinal = \ "\[InvisibleSpace]1145349707\/10000000000\[InvisibleSpace]" = "\ \[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " dFinal found: dNumeratorFinal = ", 1145349707, " dDenominatorFinal = ", 10000000000, " dFinal = ", Rational[ 1145349707, 10000000000], " = ", 0.1145349707`10., " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ \({0.1145349707`10. , 7}\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 17. Linear Search SmirnovD Bandwidths with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the Mathematica function \ KS1SidedBandwidthByLinearSearchSmirnovD which finds the bandwidth using \ linear search and SmirnovD. Sample intermediate output is given in \ subsection 17.1.\ \>", "Text"], Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchSmirnovD[alphaIn_, \ sampleSizeIn_, \ numberDigitsPrecisionIn_, \ intermediateOutput_]\ := \ Module[{alpha, \ sampleSize, \ numberDigitsPrecision, \ dMD, \ rD, \ dLowLimitNumerator, \ dLowLimitDenominator, \ dLowLimitAlpha, \ dHighLimitNumerator, \ dHighLimitDenominator, \ dHighLimitAlpha, \ dNumeratorIncrement, \ numberTries, \ dTryNumerator, \ dTryDenominator, \ dInput, \ alphaOutput, \ dHighLimitMinusLowLimit, \ dNumeratorFinal, \ dDenominatorFinal, \ dFinal}, \[IndentingNewLine] (*\ Calculate\ one - sided\ one\ sample\ KS\ bandwidth\ to\ *) \[IndentingNewLine] (*\ \ \ \ \ numberDigitsPrecisionIn\ significant\ digits\ *) \[IndentingNewLine] \ (*\ \ \ \ for\ sample\ size\ sampleSizeIn\ and\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \(alphaIn\)\(.\)\ \ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]alpha\ = \ Rationalize[alphaIn, \ 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]numberDigitsPrecision\ = \ Floor[numberDigitsPrecisionIn]; \[IndentingNewLine]numberTries\ = \ \ 0; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\", \ "\< \ sampleSize = \>", \ sampleSize, \ "\< alpha = \>", \ alpha, \ "\< = \>", \ N[alpha], "\< numberDigitsPrecision = \>", \ numberDigitsPrecision, "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ inputs\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[alpha\ \[LessEqual] \ 0, \ Print["\", \ alpha, \ "\< is less than or equal to zero.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[GreaterEqual] \ 1, \ Print["\", \ alpha, \ "\< is greater than or equal to one.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ numberDigitsPrecision\ < \ 2, \ Print["\", \ numberDigitsPrecision, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine] (*\ Use\ Maag\ and\ Dicaire\ MD\ approximation\ to\ get\ initial\ value\ \ of\ d, \ dMD\ *) \[IndentingNewLine]dMD\ = N[Sqrt[Log[ alpha]/\((\(-2\)\ *\ sampleSize)\)]\ - \ \((1/\((6* sampleSize)\))\), numberDigitsPrecision]; \[IndentingNewLine]If[dMD\ > \ 1, \ dMD\ = \ 1]; \[IndentingNewLine]If[dMD\ < \ 0, \ dMD\ = \ 0]; \[IndentingNewLine]rD\ = \ RealDigits[dMD]; \[IndentingNewLine] (*\ Using\ dMD, \ create\ the\ first\ guess\ for\ d\ and\ determine\ whether\ it\ is\ \ lower\ or\ higher\ than\ the\ actual\ value\ \ *) \[IndentingNewLine]alphaOutput\ = \ SmirnovDKS1SidedRTRational[dMD, sampleSize]; \[IndentingNewLine]numberTries\ = \ 1; \[IndentingNewLine]If[alphaOutput\ > \ alpha, \ Goto[InitialLowLimit], \ Goto[InitialHighLimit]\ ]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ lower\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialLowLimit]; \[IndentingNewLine]dLowLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dLowLimitNumerator\ = \ \ Floor[dMD\ *\ \ dLowLimitDenominator]; \[IndentingNewLine]dLowLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a low limit: dMD = \ \>", \ dMD, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dLowLimit, \ find\ dHighLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dLowLimitDenominator; \[IndentingNewLine]Label[ InitialHighLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dLowLimitNumerator\ + \ dNumeratorIncrement]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[dInput\ \[GreaterEqual] \ 1, \ dHighLimitNumerator\ = \ dLowLimitNumerator; \ dHighLimitDenominator\ = \ dLowLimitNumerator; \ dHighLimitAlpha\ = \ Rationalize[0, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ SmirnovDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial HighLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[LessEqual] \ alpha, \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dLowLimit\ found\ trying\ to\ find\ initial\ dHighLimit\ \ *) \[IndentingNewLine]dLowLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dLowLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dLowLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial HighLimit a new LowLimit \ was found: dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dLowLimitAlpha = \>", \ \ N[ dLowLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialHighLimitIteration]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ highed\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialHighLimit]; \[IndentingNewLine]dHighLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dHighLimitNumerator\ = \ \ Floor[dMD\ *\ \ dHighLimitDenominator]; \[IndentingNewLine]dHighLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a high limit: dMD = \ \>", \ dMD, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dHighLimit, \ find\ dLowLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dHighLimitDenominator; \[IndentingNewLine]Label[ InitialLowLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dHighLimitNumerator\ - \ dNumeratorIncrement]; \[IndentingNewLine]If[ dTryNumerator\ < \ 10^\((numberDigitsPrecision - 1)\), \ dHighLimitDenominator\ = \ Floor[dHighLimitDenominator*10]; \ \ dHighLimitNumerator\ = \ Floor[dHighLimitNumerator*10]; \ \ dTryDenominator\ = \ Floor[dTryDenominator*10]; \ \ \ \ dTryNumerator\ = \ Floor[dTryNumerator*10]; \ dNumeratorIncrement\ = \ Floor[dNumeratorIncrement*10]\ \ ]; \[IndentingNewLine]dInput\ = \ \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[ dInput\ \[LessEqual] \ 0, \ dLowLimitNumerator\ = \ dHighLimitNumerator; \ dLowLimitDenominator\ = \ dHighLimitNumerator; \ dLowLimitAlpha\ = \ Rationalize[1, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ SmirnovDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial LowLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[GreaterEqual] \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dHighLimit\ found\ trying\ to\ find\ initial\ dLowLimit\ \ *) \[IndentingNewLine]dHighLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dHighLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dHighLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial LowLimit a new HighLimit \ was found: dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator, \ "\< dHighLimitAlpha = \>", \ \ N[ dHighLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialLowLimitIteration]; \[IndentingNewLine] (*\ Initial\ dLowLimit\ and\ dHighLimit\ found\ \ *) \[IndentingNewLine]Label[ InitialLowAndHighLimitsFound]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Initial Low and High Limits found: \ dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Begin\ search\ between\ dLowLimit\ and\ dHighLimit\ \ *) \[IndentingNewLine]Label[ SearchIteration]; \[IndentingNewLine]dHighLimitMinusLowLimit\ = \ Floor[dHighLimitNumerator\ - \ dLowLimitNumerator]; \[IndentingNewLine]If[ dHighLimitMinusLowLimit\ \[LessEqual] \ 1, \ Goto[dFinalDetermination]\ ]; \[IndentingNewLine]dTryDenominator\ \ = \ dHighLimitDenominator; \[IndentingNewLine]dTryNumerator\ = \ Floor[Rationalize[ dLowLimitNumerator\ + \ dHighLimitMinusLowLimit*\((dLowLimitAlpha\ - \ alpha)\)/\((dLowLimitAlpha\ - \ dHighLimitAlpha)\), \ 0]]; \[IndentingNewLine]If[ dTryNumerator\ \[GreaterEqual] \ dHighLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ - \ 1]\ ]; \[IndentingNewLine]If[ dTryNumerator \[LessEqual] \ dLowLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ + \ 1]\ ]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ SmirnovDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Search: dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha]]]; \[IndentingNewLine]If[ alphaOutput\ > \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput;\ , \ \ \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput;]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ If[alphaOutput\ > \ alpha, \ Print["\< New search above is a new LowLimit\>"], \ Print["\< New search above is a new HighLimit\>"]\ ]\ ]; \ \[IndentingNewLine]Goto[SearchIteration]; \[IndentingNewLine] (*\ Determine\ whether\ LowLimit\ or\ HighLimit\ is\ dFinal\ \ *) \[IndentingNewLine]Label[dFinalDetermination]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Low and High Limits found: dLowLimitNumerator = \>", \ \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator]]; \[IndentingNewLine]dTryDenominator\ = \ Floor[dLowLimitDenominator\ *\ 10]; \[IndentingNewLine]dTryNumerator\ = \ Floor[dLowLimitNumerator\ *\ 10\ + \ 5]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ SmirnovDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Determine whether LowLimit or HighLimit is dFinal: \ dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ < \ alpha, \ \ dNumeratorFinal\ = \ dLowLimitNumerator; \ dDenominatorFinal\ = \ dLowLimitDenominator;\ \ , \ dNumeratorFinal\ = \ dHighLimitNumerator; \ dDenominatorFinal\ = \ dHighLimitDenominator;\ \ ]; \[IndentingNewLine]dFinal\ = \ Rationalize[\ dNumeratorFinal/dDenominatorFinal, \ 0]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\< dFinal found: dNumeratorFinal = \>", \ dNumeratorFinal, \ "\< dDenominatorFinal = \>", \ dDenominatorFinal\ , \ "\< dFinal = \>", \ dFinal, \ "\< = \>", \ N[dFinal, \ numberDigitsPrecision], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]{N[dFinal, \ numberDigitsPrecision], \ numberTries}\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(SmirnovDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ term, \ leftTailProbability, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Smirnov\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ N . \ V . \ Smirnov\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Uspekhi\ Mat . \ Nauk\ 10\ \((1944)\), \ pp . \ 179 - 206\ \(\((in\ Russian)\)\(.\)\)\ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ \((1 - d)\)]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[1\ - \ d, \ 0]; \[IndentingNewLine]thirdTerm\ = \ d; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^sampleSize/thirdTerm, \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ \((1/sampleSize)\)\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j)\)\ *\ thirdTerm^\((j\ - \ 1)\))\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[d\ *\ sumTerms, \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ 17.1 Linear Search SmirnovD Bandwidths Sample Intermediate Output\ \>", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchSmirnovD[0.25, \ 50, \ 10, \ 3]\)], "Input"], Cell[BoxData[ InterpretationBox[\("KS1SidedBandwidthByLinearSearchSmirnovD:"\ \[InvisibleSpace]" sampleSize = "\[InvisibleSpace]50\[InvisibleSpace]" \ alpha = "\[InvisibleSpace]1\/4\[InvisibleSpace]" = "\[InvisibleSpace]0.25`\ \[InvisibleSpace]" numberDigitsPrecision = "\[InvisibleSpace]10\ \[InvisibleSpace]" numberTries = "\[InvisibleSpace]0\), SequenceForm[ "KS1SidedBandwidthByLinearSearchSmirnovD:", " sampleSize = ", 50, " alpha = ", Rational[ 1, 4], " = ", .25, " numberDigitsPrecision = ", 10, " numberTries = ", 0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Maag and Dicaire approximation is a low limit: \ dMD = "\[InvisibleSpace]0.1144076689182141357664946908`10. \[InvisibleSpace]" \ dLowLimitNumerator = "\[InvisibleSpace]1144076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2507521869671434`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries \ = "\[InvisibleSpace]1\), SequenceForm[ " Maag and Dicaire approximation is a low limit: dMD = ", 0.1144076689182141357664946908`10., " dLowLimitNumerator = ", 1144076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25075218696714341, " is greater than alpha = ", .25, " numberTries = ", 1], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]1000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]2\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 1000000, " dTryNumerator = ", 1145076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145076689`10., " alphaOutput = ", .25016119688080912, " numberTries = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" In trying to find the initial HighLimit a new \ LowLimit was found: dLowLimitNumerator = "\[InvisibleSpace]1145076689\ \[InvisibleSpace]" dLowLimitDenominator = "\[InvisibleSpace]10000000000\ \[InvisibleSpace]" dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\), SequenceForm[ " In trying to find the initial HighLimit a new LowLimit was found: \ dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Try to find the initial HighLimit: \ dNumeratorIncrement = "\[InvisibleSpace]10000000\[InvisibleSpace]" \ dTryNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1155076689`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Try to find the initial HighLimit: dNumeratorIncrement = ", 10000000, " dTryNumerator = ", 1155076689, " dTryDenominator = ", 10000000000, " dInput = ", 0.1155076689`10., " alphaOutput = ", .24430010508896607, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Initial Low and High Limits found: \ dLowLimitNumerator = "\[InvisibleSpace]1145076689\[InvisibleSpace]" \ dLowLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dLowLimitAlpha = "\[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" is \ greater than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" \ dHighLimitNumerator = "\[InvisibleSpace]1155076689\[InvisibleSpace]" \ dHighLimitDenominator = "\[InvisibleSpace]10000000000\[InvisibleSpace]" \ dHighLimitAlpha = "\[InvisibleSpace]0.24430010508896607`\[InvisibleSpace]" is \ less than alpha = "\[InvisibleSpace]0.25`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]3\), SequenceForm[ " Initial Low and High Limits found: dLowLimitNumerator = ", 1145076689, " dLowLimitDenominator = ", 10000000000, " dLowLimitAlpha = ", .25016119688080912, " is greater than alpha = ", .25, " dHighLimitNumerator = ", 1155076689, " dHighLimitDenominator = ", 10000000000, " dHighLimitAlpha = ", .24430010508896607, " is less than alpha = ", .25, " numberTries = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145351717\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145351717`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.24999881348012207`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]4\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1155076689\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24430010508896607`\), SequenceForm[ " Search: dTryNumerator = ", 1145351717, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145351717`10., " alphaOutput = ", .24999881348012207, " numberTries = ", 4, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1155076689, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24430010508896607], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349707\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]5\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145351717\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.24999881348012207`\), SequenceForm[ " Search: dTryNumerator = ", 1145349707, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349707`10., " alphaOutput = ", .249999999991038, " numberTries = ", 5, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145351717, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .24999881348012207], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new HighLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Search: dTryNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dTryDenominator = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.1145349706`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]6\[InvisibleSpace]" dLowLimitNumerator = \ "\[InvisibleSpace]1145076689\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.2501611968808091`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\), SequenceForm[ " Search: dTryNumerator = ", 1145349706, " dTryDenominator = ", 10000000000, " dInput = ", 0.1145349706`10., " alphaOutput = ", .25000000058134286, " numberTries = ", 6, " dLowLimitNumerator = ", 1145076689, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25016119688080912, " dHighLimitAlpha = ", .249999999991038], Editable->False]], "Print"], Cell[BoxData[ \(" New search above is a new LowLimit"\)], "Print"], Cell[BoxData[ InterpretationBox[\(" Low and High Limits found: dLowLimitNumerator = \ "\[InvisibleSpace]1145349706\[InvisibleSpace]" dHighLimitNumerator = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dLowLimitAlpha = "\ \[InvisibleSpace]0.25000000058134286`\[InvisibleSpace]" dHighLimitAlpha = "\ \[InvisibleSpace]0.249999999991038`\[InvisibleSpace]" dLowLimitDenominator \ = "\[InvisibleSpace]10000000000\[InvisibleSpace]" dHighLimitDenominator = "\ \[InvisibleSpace]10000000000\), SequenceForm[ " Low and High Limits found: dLowLimitNumerator = ", 1145349706, " dHighLimitNumerator = ", 1145349707, " dLowLimitAlpha = ", .25000000058134286, " dHighLimitAlpha = ", .249999999991038, " dLowLimitDenominator = ", 10000000000, " dHighLimitDenominator = ", 10000000000], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Determine whether LowLimit or HighLimit is \ dFinal: dTryNumerator = "\[InvisibleSpace]11453497065\[InvisibleSpace]" \ dTryDenominator = "\[InvisibleSpace]100000000000\[InvisibleSpace]" dInput = \ "\[InvisibleSpace]0.11453497065`10. \[InvisibleSpace]" alphaOutput = "\ \[InvisibleSpace]0.2500000002861904`\[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " Determine whether LowLimit or HighLimit is dFinal: dTryNumerator \ = ", 11453497065, " dTryDenominator = ", 100000000000, " dInput = ", 0.11453497065`10., " alphaOutput = ", .2500000002861904, " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" dFinal found: dNumeratorFinal = "\ \[InvisibleSpace]1145349707\[InvisibleSpace]" dDenominatorFinal = "\ \[InvisibleSpace]10000000000\[InvisibleSpace]" dFinal = \ "\[InvisibleSpace]1145349707\/10000000000\[InvisibleSpace]" = "\ \[InvisibleSpace]0.1145349707`10. \[InvisibleSpace]" numberTries = "\ \[InvisibleSpace]7\), SequenceForm[ " dFinal found: dNumeratorFinal = ", 1145349707, " dDenominatorFinal = ", 10000000000, " dFinal = ", Rational[ 1145349707, 10000000000], " = ", 0.1145349707`10., " numberTries = ", 7], Editable->False]], "Print"], Cell[BoxData[ \({0.1145349707`10. , 7}\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 18. Produce Files of Bandwidths with Sample Intermediate Output\ \>", "Section"], Cell["\<\ The following is the code of the \[AliasDelimiter] which finds bandwidths \ using linear search with DwassAltD and writes these bandwidths to a comma \ delimited file for input into Excel and a text file that can be used as input \ into timing programs. Sample intermediate output is given in subsection \ 18.1. For the intermediate output in subsection 18.1, subsection 18.2 \ contains the file produced with the file name contained in the variable: \ outputFileName. For the file in subsection 18.2, the character input into \ separatorString is used as a delimiter so if separatorString contains a \ comma, the file can be read into Excel. For the intermediate output in \ subsection 18.1, subsection 18.3 contains the file produced with the file \ name contained in the variable: exportFileName. The file in subsection 18.3 \ is designed to be used as input to the functions listed in sections 19 \ through 23.\ \>", "Text"], Cell[BoxData[ \(KS1SidedOneSampleBandwidthsToFile[sampleSizeVectorIn_, \ alphaVectorIn_, \ desiredPrecisionIn_, \ intermediateOutput_, \ outputFileName_, \ howToOpenFile_, \ separatorString_, \ exportFileName_]\ \ := \ Module[{sampleSize, \ numberSampleSizes, alpha, \ numberOfAlphas, dataVectorDimensions, \ outputFileNumber, \ sampleSizeVectorIndex, \ alphaVectorIndex, rightTailProbability, \ functionOutput, \ functionTimeString, \ timeString, \ desiredPrecision, \ desiredPrecisionPlusOne, \ dCalculated, \ sampleSizeByAlpha, \ ssbaIndex, ssbaNumberColumns, \ ssbaNumberRows, \ digitsIndex, \ rD, \ dCalculatedString, \ dCalculatedStringLength}, \[IndentingNewLine] (*\ Generate\ d\ and\ timings\ for\ an\ alpha\ and\ sampleSize\ and\ \ put\ *) \[IndentingNewLine] (*\ \ \ \ into\ matrix\ \ \(\(sampleSizeByAlpha\)\(.\)\)\ *) \[IndentingNewLine] (*\ Export\ sampleSizeByAlpha\ table\ to\ exportFileName\ and\ also\ \ *) \[IndentingNewLine] (*\ \ \ \ put\ into\ file, \ \(\(outputFileName\)\(.\)\ \)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1\ = \ increasing\ amount\ of\ intermediate\ output\ *) \[IndentingNewLine] \ (*\ \ \ \ \ \ \ \ \ \ \ 2\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ separatorString\ - \ the\ character\ used\ to\ separate\ the\ output\ in\ file\ \ \(\(exportFileName\)\(.\)\)\ *) \[IndentingNewLine] (*\ Open\ \(file : \ howToOpenFile\) = 0, \ use\ OpenWrite\ which\ creates\ a\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ new\ file\ and\ destroys\ an\ old\ file\ \ *) \ (*\ \ \ \ \ \ \ \ \ \ \ \ howToOpenFile = 1, \ use\ OpenAppend\ which\ opens\ file\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ and\ appends\ output\ to\ end\ of\ that\ \ \(\(file\)\(.\)\)\ \ *) \[IndentingNewLine]\ dataVectorDimensions\ = \ Dimensions[ sampleSizeVectorIn]; \[IndentingNewLine]numberSampleSizes\ = \ \ \ dataVectorDimensions[\([1]\)]; \[IndentingNewLine]dataVectorDimensions\ = \ Dimensions[ alphaVectorIn]; \[IndentingNewLine]numberOfAlphas\ = \ \ \ dataVectorDimensions[\([1]\)]; \[IndentingNewLine]desiredPrecision\ = \ Floor[desiredPrecisionIn]; \ \[IndentingNewLine]desiredPrecisionPlusOne\ = \ \ desiredPrecision\ + \ 1; \[IndentingNewLine]ssbaNumberColumns\ = \ desiredPrecision\ + \ 7; \[IndentingNewLine]ssbaNumberRows\ = \ numberSampleSizes\ *\ numberOfAlphas\ + \ 1; \[IndentingNewLine]sampleSizeByAlpha\ = \ Array[0, \ {ssbaNumberRows, \ ssbaNumberColumns}]; \[IndentingNewLine]sampleSizeByAlpha[\([1, 1]\)]\ \ = \ "\"; \ \[IndentingNewLine]sampleSizeByAlpha[\([1, 2]\)]\ \ = \ "\"; \ \[IndentingNewLine]sampleSizeByAlpha[\([1, 3]\)]\ \ = \ "\"; \ \[IndentingNewLine]sampleSizeByAlpha[\([1, 4]\)]\ \ = \ "\"; \ \[IndentingNewLine]sampleSizeByAlpha[\([1, 5]\)]\ \ = \ "\"; \[IndentingNewLine]Do[\ \[IndentingNewLine]\(sampleSizeByAlpha[\([1, digitsIndex\ ]\)]\ \ = \ digitsIndex\ - \ 5;\)\[IndentingNewLine], \ {digitsIndex, \ 6, \ \ ssbaNumberColumns, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]\ ssbaIndex\ = \ 1; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ outputFileNumber\ = \ OpenWrite[outputFileName], \ outputFileNumber\ = \ OpenAppend[outputFileName]]; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ \[IndentingNewLine]WriteString[ outputFileNumber, \ "\", \ \ desiredPrecision, "\< for a specified sampleSize \ and alpha\>"]; \[IndentingNewLine]WriteString[ outputFileNumber, \ "\<\n\>"\ ]; \[IndentingNewLine]WriteString[ outputFileNumber, \ "\"]; \[IndentingNewLine]WriteString[ outputFileNumber, \ "\<\n\>"\ ];\[IndentingNewLine]]; \ \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ \[IndentingNewLine]\(Print["\<\ KS1SidedOneSampleBandwidthsToFile: outputFileName = \>", \ outputFileName, \ "\<, howToOpenFile = \>", \ howToOpenFile, \ "\<, separatorString = '\>", \ separatorString, \ "\<'\>", "\< exportFileName = \>", \ exportFileName, \ "\<, sampleSizeVectorIn = \>", \ sampleSizeVectorIn, \ "\< with \>", \ numberSampleSizes, \ "\< sampleSizes, and alphaVectorIn = \ \>", \ alphaVectorIn, \ "\< with \>", \ numberOfAlphas, \ "\< alpha's\>"];\)\[IndentingNewLine]]; \ \[IndentingNewLine] (*\ Begin\ \(\(iterations\)\(.\)\)\ *) \[IndentingNewLine]Do[\ \[IndentingNewLine]sampleSize\ = \ sampleSizeVectorIn[\([sampleSizeVectorIndex]\)]; \ \[IndentingNewLine]Do[\[IndentingNewLine]ssbaIndex\ = \ ssbaIndex\ + \ 1; \[IndentingNewLine]alpha\ = \ alphaVectorIn[\([alphaVectorIndex]\)]; \ \[IndentingNewLine]functionOutput\ = \ \ Timing[ KS1SidedBandwidthByLinearSearchDwassAltD[alpha, \ sampleSize, \ desiredPrecision, \ 0]\ ]\ ; \[IndentingNewLine]dCalculated\ = \ functionOutput[\([2]\)]; \[IndentingNewLine]rD\ = \ RealDigits[ dCalculated]; \[IndentingNewLine]dCalculatedString\ = \ ToString[ dCalculated]; \[IndentingNewLine]dCalculatedStringLength\ = \ \ StringLength[dCalculatedString]\ - \ 2; \[IndentingNewLine]sampleSizeByAlpha[\([ssbaIndex, \ 1]\)]\ = \ sampleSize; \[IndentingNewLine]sampleSizeByAlpha[\([ssbaIndex, \ \ 2]\)]\ = \ alpha; \[IndentingNewLine]sampleSizeByAlpha[\([ssbaIndex, \ 3]\)]\ = \ dCalculatedString; \ \[IndentingNewLine]sampleSizeByAlpha[\([ssbaIndex, \ 4]\)]\ = \ rD[\([2]\)]; \[IndentingNewLine]sampleSizeByAlpha[\([ssbaIndex, \ \ 5]\)]\ = \ dCalculatedStringLength; \[IndentingNewLine]Do[\ \[IndentingNewLine]\(sampleSizeByAlpha[\([ssbaIndex, digitsIndex\ ]\)]\ \ = \ 0;\)\[IndentingNewLine], \ {digitsIndex, \ 6, \ \ ssbaNumberColumns, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]Do[\ \[IndentingNewLine]\(If[\ digitsIndex\ + \ 5\ \[LessEqual] \ ssbaNumberColumns\ , sampleSizeByAlpha[\([ssbaIndex, digitsIndex\ + \ 5\ ]\)]\ \ = \ StringTake[ dCalculatedString, \ {digitsIndex\ + \ 2\ - \ rD[\([2]\)]}]\ ];\)\[IndentingNewLine], \ \ {digitsIndex, \ 1, \ dCalculatedStringLength\ + \ rD[\([2]\)], \ 1}\[IndentingNewLine]]; \ \[IndentingNewLine]rightTailProbability\ = \ N[DwassAltDKS1SidedRTRational[dCalculated, \ \ sampleSize], \ desiredPrecision]; \[IndentingNewLine]functionTimeString\ = \ \ functionOutput[\([1]\)]; \[IndentingNewLine]timeString\ = \ functionTimeString\ /. \ Second \[Rule] 1; \[IndentingNewLine]WriteString[ outputFileNumber, \ ToString[alpha, \ FortranForm], \ separatorString, ToString[sampleSize, \ FortranForm], \ separatorString, ToString[desiredPrecision, \ FortranForm], \ separatorString, \ timeString, \ separatorString, ToString[\ rightTailProbability, \ FortranForm], \ separatorString, ToString[dCalculated, \ FortranForm], \ "\<\n\>"]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \[IndentingNewLine]\(Print["\", \ alpha, \ "\< sampleSize = \>", \ sampleSize\ , \ "\< desiredPrecision = \>", \ desiredPrecision, \ \ "\< timeInSeconds = \>", \ timeString, \ "\< actualAlpha = \>", \ rightTailProbability, \ "\< dCalculated = \>", \ dCalculated];\)\[IndentingNewLine]];\[IndentingNewLine], \ \ {alphaVectorIndex, \ 1, \ numberOfAlphas\ , \ 1}\[IndentingNewLine]];\[IndentingNewLine], \ \ {sampleSizeVectorIndex, \ 1, \ numberSampleSizes\ , \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ \ Print["\< sampleSizeByAlpha = \>", \ sampleSizeByAlpha]\ ]; \[IndentingNewLine]Export[ exportFileName, \ sampleSizeByAlpha, \ "\"]; \[IndentingNewLine]Close[ outputFileNumber]; \[IndentingNewLine]numberSampleSizes\ \[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(KS1SidedBandwidthByLinearSearchDwassAltD[alphaIn_, \ sampleSizeIn_, \ numberDigitsPrecisionIn_, \ intermediateOutput_]\ := \ Module[{alpha, \ sampleSize, \ numberDigitsPrecision, \ dMD, \ rD, \ dLowLimitNumerator, \ dLowLimitDenominator, \ dLowLimitAlpha, \ dHighLimitNumerator, \ dHighLimitDenominator, \ dHighLimitAlpha, \ dNumeratorIncrement, \ numberTries, \ dTryNumerator, \ dTryDenominator, \ dInput, \ alphaOutput, \ dHighLimitMinusLowLimit, \ dNumeratorFinal, \ dDenominatorFinal, \ dFinal}, \[IndentingNewLine] (*\ Calculate\ one - sided\ one\ sample\ KS\ bandwidth\ to\ *) \[IndentingNewLine] (*\ \ \ \ \ numberDigitsPrecisionIn\ significant\ digits\ *) \[IndentingNewLine] \ (*\ \ \ \ for\ sample\ size\ sampleSizeIn\ and\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \(alphaIn\)\(.\)\ \ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]alpha\ = \ Rationalize[alphaIn, \ 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]numberDigitsPrecision\ = \ Floor[numberDigitsPrecisionIn]; \[IndentingNewLine]numberTries\ = \ \ 0; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\", \ "\< \ sampleSize = \>", \ sampleSize, \ "\< alpha = \>", \ alpha, \ "\< = \>", \ N[alpha], "\< numberDigitsPrecision = \>", \ numberDigitsPrecision, "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ inputs\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[alpha\ \[LessEqual] \ 0, \ Print["\", \ alpha, \ "\< is less than or equal to zero.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ alpha\ \[GreaterEqual] \ 1, \ Print["\", \ alpha, \ "\< is greater than or equal to one.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine]If[ numberDigitsPrecision\ < \ 2, \ Print["\", \ numberDigitsPrecision, \ "\< is less than 2.\>"]; \ dFinal\ = \ \(-99\); \ Goto[ExitNow]\ ]; \[IndentingNewLine] (*\ Use\ Maag\ and\ Dicaire\ MD\ approximation\ to\ get\ initial\ value\ \ of\ d, \ dMD\ *) \[IndentingNewLine]dMD\ = N[Sqrt[Log[ alpha]/\((\(-2\)\ *\ sampleSize)\)]\ - \ \((1/\((6* sampleSize)\))\), numberDigitsPrecision]; \[IndentingNewLine]If[dMD\ > \ 1, \ dMD\ = \ 1]; \[IndentingNewLine]If[dMD\ < \ 0, \ dMD\ = \ 0]; \[IndentingNewLine]rD\ = \ RealDigits[dMD]; \[IndentingNewLine] (*\ Using\ dMD, \ create\ the\ first\ guess\ for\ d\ and\ determine\ whether\ it\ is\ \ lower\ or\ higher\ than\ the\ actual\ value\ \ *) \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dMD, sampleSize]; \[IndentingNewLine]numberTries\ = \ 1; \[IndentingNewLine]If[alphaOutput\ > \ alpha, \ Goto[InitialLowLimit], \ Goto[InitialHighLimit]\ ]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ lower\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialLowLimit]; \[IndentingNewLine]dLowLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dLowLimitNumerator\ = \ \ Floor[dMD\ *\ \ dLowLimitDenominator]; \[IndentingNewLine]dLowLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a low limit: dMD = \ \>", \ dMD, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dLowLimit, \ find\ dHighLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dLowLimitDenominator; \[IndentingNewLine]Label[ InitialHighLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dLowLimitNumerator\ + \ dNumeratorIncrement]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[dInput\ \[GreaterEqual] \ 1, \ dHighLimitNumerator\ = \ dLowLimitNumerator; \ dHighLimitDenominator\ = \ dLowLimitNumerator; \ dHighLimitAlpha\ = \ Rationalize[0, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial HighLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[LessEqual] \ alpha, \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dLowLimit\ found\ trying\ to\ find\ initial\ dHighLimit\ \ *) \[IndentingNewLine]dLowLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dLowLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dLowLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial HighLimit a new LowLimit \ was found: dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dLowLimitAlpha = \>", \ \ N[ dLowLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialHighLimitIteration]; \[IndentingNewLine] (*\ Initial\ guess\ dMD\ is\ highed\ than\ the\ actual\ d\ \ *) \[IndentingNewLine]Label[ InitialHighLimit]; \[IndentingNewLine]dHighLimitDenominator\ = \ Floor[10^\((numberDigitsPrecision\ - \ rD[\([2]\)])\)]; \[IndentingNewLine]dHighLimitNumerator\ = \ \ Floor[dMD\ *\ \ dHighLimitDenominator]; \[IndentingNewLine]dHighLimitAlpha\ \ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Maag and Dicaire approximation is a high limit: dMD = \ \>", \ dMD, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Based\ on\ dHighLimit, \ find\ dLowLimit\ *) \[IndentingNewLine]If[ numberDigitsPrecision\ > \ 4, \ \(dNumeratorIncrement\ = \ Floor[10^\((numberDigitsPrecision\ - \ 5)\)];\)\ , \ dNumeratorIncrement\ = \ 1]; \[IndentingNewLine]dTryDenominator\ = \ dHighLimitDenominator; \[IndentingNewLine]Label[ InitialLowLimitIteration]; \[IndentingNewLine]dNumeratorIncrement\ \ = \ dNumeratorIncrement\ *\ 10; \[IndentingNewLine]dTryNumerator\ = \ \ Floor[ dHighLimitNumerator\ - \ dNumeratorIncrement]; \[IndentingNewLine]If[ dTryNumerator\ < \ 10^\((numberDigitsPrecision - 1)\), \ dHighLimitDenominator\ = \ Floor[dHighLimitDenominator*10]; \ \ dHighLimitNumerator\ = \ Floor[dHighLimitNumerator*10]; \ \ dTryDenominator\ = \ Floor[dTryDenominator*10]; \ \ \ \ dTryNumerator\ = \ Floor[dTryNumerator*10]; \ dNumeratorIncrement\ = \ Floor[dNumeratorIncrement*10]\ \ ]; \[IndentingNewLine]dInput\ = \ \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]If[ dInput\ \[LessEqual] \ 0, \ dLowLimitNumerator\ = \ dHighLimitNumerator; \ dLowLimitDenominator\ = \ dHighLimitNumerator; \ dLowLimitAlpha\ = \ Rationalize[1, \ 0]; \ Goto[InitialLowAndHighLimitsFound]\ ]; \ \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Try to find the initial LowLimit: dNumeratorIncrement \ = \>", \ dNumeratorIncrement, \ "\< dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ \[GreaterEqual] \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput; \ Goto[InitialLowAndHighLimitsFound]\ ]; \[IndentingNewLine] (*\ New\ dHighLimit\ found\ trying\ to\ find\ initial\ dLowLimit\ \ *) \[IndentingNewLine]dHighLimitNumerator\ = \ dTryNumerator; \[IndentingNewLine]dHighLimitDenominator\ = \ dTryDenominator; \[IndentingNewLine]dHighLimitAlpha\ = \ alphaOutput; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< In trying to find the initial LowLimit a new HighLimit \ was found: dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator, \ "\< dHighLimitAlpha = \>", \ \ N[ dHighLimitAlpha]]]; \[IndentingNewLine]Goto[ InitialLowLimitIteration]; \[IndentingNewLine] (*\ Initial\ dLowLimit\ and\ dHighLimit\ found\ \ *) \[IndentingNewLine]Label[ InitialLowAndHighLimitsFound]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Initial Low and High Limits found: \ dLowLimitNumerator = \>", \ dLowLimitNumerator\ , \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator\ , \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< is greater than alpha = \>", \ \ N[ alpha], \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator\ , \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator\ , \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< is less than alpha = \>", \ \ N[ alpha], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine] (*\ Begin\ search\ between\ dLowLimit\ and\ dHighLimit\ \ *) \[IndentingNewLine]Label[ SearchIteration]; \[IndentingNewLine]dHighLimitMinusLowLimit\ = \ Floor[dHighLimitNumerator\ - \ dLowLimitNumerator]; \[IndentingNewLine]If[ dHighLimitMinusLowLimit\ \[LessEqual] \ 1, \ Goto[dFinalDetermination]\ ]; \[IndentingNewLine]dTryDenominator\ \ = \ dHighLimitDenominator; \[IndentingNewLine]dTryNumerator\ = \ Floor[Rationalize[ dLowLimitNumerator\ + \ dHighLimitMinusLowLimit*\((dLowLimitAlpha\ - \ alpha)\)/\((dLowLimitAlpha\ - \ dHighLimitAlpha)\), \ 0]]; \[IndentingNewLine]If[ dTryNumerator\ \[GreaterEqual] \ dHighLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ - \ 1]\ ]; \[IndentingNewLine]If[ dTryNumerator \[LessEqual] \ dLowLimitNumerator, \ dTryNumerator\ = \ Floor[dTryNumerator\ + \ 1]\ ]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Search: dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries, \ "\< dLowLimitNumerator = \>", \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha]]]; \[IndentingNewLine]If[ alphaOutput\ > \ alpha, \ dLowLimitNumerator\ = \ dTryNumerator; \ dLowLimitDenominator\ = \ dTryDenominator; \ dLowLimitAlpha\ = \ alphaOutput;\ , \ \ \ dHighLimitNumerator\ = \ dTryNumerator; \ dHighLimitDenominator\ = \ dTryDenominator; \ dHighLimitAlpha\ = \ alphaOutput;]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ If[alphaOutput\ > \ alpha, \ Print["\< New search above is a new LowLimit\>"], \ Print["\< New search above is a new HighLimit\>"]\ ]\ ]; \ \[IndentingNewLine]Goto[SearchIteration]; \[IndentingNewLine] (*\ Determine\ whether\ LowLimit\ or\ HighLimit\ is\ dFinal\ \ *) \[IndentingNewLine]Label[dFinalDetermination]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 2, \ Print["\< Low and High Limits found: dLowLimitNumerator = \>", \ \ dLowLimitNumerator, \ "\< dHighLimitNumerator = \>", \ dHighLimitNumerator, \ "\< dLowLimitAlpha = \>", \ N[dLowLimitAlpha], \ "\< dHighLimitAlpha = \>", \ N[dHighLimitAlpha], \ "\< dLowLimitDenominator = \>", \ dLowLimitDenominator, \ "\< dHighLimitDenominator = \>", \ dHighLimitDenominator]]; \[IndentingNewLine]dTryDenominator\ = \ Floor[dLowLimitDenominator\ *\ 10]; \[IndentingNewLine]dTryNumerator\ = \ Floor[dLowLimitNumerator\ *\ 10\ + \ 5]; \[IndentingNewLine]dInput\ = \ Rationalize[dTryNumerator/dTryDenominator, \ 0]; \[IndentingNewLine]alphaOutput\ = \ DwassAltDKS1SidedRTRational[dInput, sampleSize]; \[IndentingNewLine]numberTries\ = \ numberTries\ + \ 1; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 3, \ Print["\< Determine whether LowLimit or HighLimit is dFinal: \ dTryNumerator = \>", \ dTryNumerator, \ "\< dTryDenominator = \>", \ dTryDenominator\ , \ "\< dInput = \>", \ N[dInput, \ numberDigitsPrecision], \ "\< alphaOutput = \>", \ \ N[ alphaOutput], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]If[ alphaOutput\ < \ alpha, \ \ dNumeratorFinal\ = \ dLowLimitNumerator; \ dDenominatorFinal\ = \ dLowLimitDenominator;\ \ , \ dNumeratorFinal\ = \ dHighLimitNumerator; \ dDenominatorFinal\ = \ dHighLimitDenominator;\ \ ]; \[IndentingNewLine]dFinal\ = \ Rationalize[\ dNumeratorFinal/dDenominatorFinal, \ 0]; \[IndentingNewLine]If[\ intermediateOutput \[GreaterEqual] \ 1, \ Print["\< dFinal found: dNumeratorFinal = \>", \ dNumeratorFinal, \ "\< dDenominatorFinal = \>", \ dDenominatorFinal\ , \ "\< dFinal = \>", \ dFinal, \ "\< = \>", \ N[dFinal, \ numberDigitsPrecision], "\< numberTries = \>", \ numberTries]]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]N[dFinal, \ numberDigitsPrecision]\[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(DwassAltDKS1SidedRTRational[dIn_, sampleSizeIn_]\ := \ \ \[IndentingNewLine]Module[{d, \ sampleSize, \ j, \ jHighLimit, \ rightTailProbability, \ binomialCoefficient, \ secondTerm, \ thirdTerm, \ sumTerms}, \[IndentingNewLine] (*\ Dwass\ Alternate\ Direct\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ \ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ dIn\ using\ rational\ \ \(\(arithmetic\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Dwass\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ \ Statistics\ 19\ \((1959)\), \ pp . \ 1024 - 1028. \ *) \[IndentingNewLine]d = Rationalize[dIn, 0]; \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]If[ d\ \[LessEqual] \ 0, \ \[IndentingNewLine]rightTailProbability\ = \ 1; \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine], \ \(If[ d\ \[GreaterEqual] \ 1, \[IndentingNewLine]rightTailProbability\ = \ 0; \ \[IndentingNewLine]Goto[ ExitNow];\[IndentingNewLine]];\)\[IndentingNewLine]]; \ \[IndentingNewLine]jHighLimit\ = \ Floor[sampleSize\ *\ d]; \[IndentingNewLine]binomialCoefficient\ = \ 1; \[IndentingNewLine]secondTerm\ \ = \ Rationalize[sampleSize\ + \ d\ *\ sampleSize, \ 0]; \[IndentingNewLine]thirdTerm\ = \ \(-d\)\ *\ sampleSize; \[IndentingNewLine]sumTerms\ = \ Rationalize[secondTerm^\((sampleSize - 1)\), \ 0]; \[IndentingNewLine]If[jHighLimit\ < \ 1, \ Goto[summationDone]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)/\ j\ , \ 0]; \[IndentingNewLine]secondTerm\ = \ Rationalize[secondTerm\ - \ 1\ , 0]; \[IndentingNewLine]thirdTerm\ = \ Rationalize[thirdTerm\ + \ 1\ , 0]; \[IndentingNewLine]sumTerms\ = \ Rationalize[ sumTerms\ + \((binomialCoefficient\ *\ secondTerm^\((sampleSize\ - \ j\ - \ 1)\)\ *\ thirdTerm^j)\), \ 0];\[IndentingNewLine], {j, \ 1, \ jHighLimit, \ 1}]; \[IndentingNewLine]Label[ summationDone]; \[IndentingNewLine]rightTailProbability\ \ = \ Rationalize[ 1\ - \ \((d\ *\ sumTerms/sampleSize^\((sampleSize\ - \ 1)\))\), \ 0]; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]rightTailProbability\ \ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["18.1 Produce Files of Bandwidths Sample Intermediate Output", \ "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(KS1SidedOneSampleBandwidthsToFile[{500, \ 1000}, \ {0.2, \ 0.1, \ 0.05, \ 0.02, \ 0.01, \ 0.001}, \ 6, \ 2, \ "\", \ 0, \ "\<,\>", \ \ "\"]\)\(\ \)\)\)], \ "Input"], Cell[BoxData[ InterpretationBox[\("KS1SidedOneSampleBandwidthsToFile: outputFileName \ = "\[InvisibleSpace]"C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.csv"\ \[InvisibleSpace]", howToOpenFile = "\[InvisibleSpace]0\[InvisibleSpace]", \ separatorString = \ '"\[InvisibleSpace]","\[InvisibleSpace]"'"\[InvisibleSpace]" exportFileName \ = "\[InvisibleSpace]"C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.dat"\ \[InvisibleSpace]", sampleSizeVectorIn = "\[InvisibleSpace]{500, 1000}\[InvisibleSpace]" with "\[InvisibleSpace]2\[InvisibleSpace]" \ sampleSizes, and alphaVectorIn = "\[InvisibleSpace]{0.2`, 0.1`, 0.05`, 0.02`, 0.01`, 0.001`}\[InvisibleSpace]" with \ "\[InvisibleSpace]6\[InvisibleSpace]" alpha's"\), SequenceForm[ "KS1SidedOneSampleBandwidthsToFile: outputFileName = ", "C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.csv", ", howToOpenFile = ", 0, ", separatorString = '", ",", "'", " exportFileName = ", "C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.dat", ", sampleSizeVectorIn = ", {500, 1000}, " with ", 2, " sampleSizes, and alphaVectorIn = ", {.20000000000000001, \ .10000000000000001, .050000000000000003, .02, .01, .001}, " with ", 6, " alpha's"], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.2`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.031000000000000028`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.20000005894562453665759910180645033282`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0397876`6.0000000000000036\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .20000000000000001, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .031000000000000028, " actualAlpha = ", 0.20000005894562453665759910180645033282`6.0000000000000036, " dCalculated = ", 0.0397876`6.0000000000000036], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.1`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.063`\[InvisibleSpace]" actualAlpha = "\ \[InvisibleSpace]0.10000036794110355952185341021304236573`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0476515`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .10000000000000001, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .063, " actualAlpha = ", 0.10000036794110355952185341021304236573`6.0000000000000036, " dCalculated = ", 0.0476515`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.05`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.031`\[InvisibleSpace]" actualAlpha = "\ \[InvisibleSpace]0.05000006375931312268984528636168303484`5.999999999999999\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.054395`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .050000000000000003, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .031, " actualAlpha = ", 0.05000006375931312268984528636168303484`5.999999999999999, " dCalculated = ", 0.054395`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.02`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.09399999999999997`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.02000006119658649900680937687576576589`5.999999999999999\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0622005`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .02, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .093999999999999972, " actualAlpha = ", 0.02000006119658649900680937687576576589`5.999999999999999, " dCalculated = ", 0.0622005`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.01`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.07799999999999996`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.01000002785747343310519460245400612127`5.999999999999999\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0675094`6.000000000000008\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .01, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .077999999999999958, " actualAlpha = ", 0.01000002785747343310519460245400612127`5.999999999999999, " dCalculated = ", 0.0675094`6.000000000000008], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.001`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]500\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.125`\[InvisibleSpace]" actualAlpha = "\ \[InvisibleSpace]0.00099998642533456242467196735886369465`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0827351`6.0000000000000036\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .001, " sampleSize = ", 500, " desiredPrecision = ", 6, " timeInSeconds = ", .125, " actualAlpha = ", 0.00099998642533456242467196735886369465`6.0000000000000036, " dCalculated = ", 0.0827351`6.0000000000000036], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.2`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]1000\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.15600000000000003`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.2000002925713250314614523999541871349`5.999999999999999\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.028202`5.999999999999999\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .20000000000000001, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .15600000000000003, " actualAlpha = ", 0.2000002925713250314614523999541871349`5.999999999999999, " dCalculated = ", 0.028202`5.999999999999999], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.1`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]1000\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.2190000000000002`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.10000003895490383334978672964601258235`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0337639`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .10000000000000001, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .21900000000000019, " actualAlpha = ", 0.10000003895490383334978672964601258235`6.0000000000000036, " dCalculated = ", 0.0337639`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.05`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]1000\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.21900000000000008`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.05000005173897737039460487538523749807`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0385338`5.99999999999999\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .050000000000000003, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .21900000000000008, " actualAlpha = ", 0.05000005173897737039460487538523749807`6.0000000000000036, " dCalculated = ", 0.0385338`5.99999999999999], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.02`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]1000\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.2809999999999999`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.02000000589885795640554626257437215209`6.0000000000000036\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0440558`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .02, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .28099999999999992, " actualAlpha = ", 0.02000000589885795640554626257437215209`6.0000000000000036, " dCalculated = ", 0.0440558`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.01`\[InvisibleSpace]" sampleSize = "\[InvisibleSpace]1000\ \[InvisibleSpace]" desiredPrecision = "\[InvisibleSpace]6\[InvisibleSpace]" \ timeInSeconds = "\[InvisibleSpace]0.2649999999999999`\[InvisibleSpace]" \ actualAlpha = \ "\[InvisibleSpace]0.00999994610329245041253763133166664328`5.99999999999999\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.047812`6.0000000000000036\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .01, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .2649999999999999, " actualAlpha = ", 0.00999994610329245041253763133166664328`5.99999999999999, " dCalculated = ", 0.047812`6.0000000000000036], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\("Bandwidth using DwassAltD Rational for alpha = "\ \[InvisibleSpace]0.001`\[InvisibleSpace]" sampleSize = \ "\[InvisibleSpace]1000\[InvisibleSpace]" desiredPrecision = "\ \[InvisibleSpace]6\[InvisibleSpace]" timeInSeconds = \ "\[InvisibleSpace]0.35999999999999965`\[InvisibleSpace]" actualAlpha = "\ \[InvisibleSpace]0.00100000031840982265685770808016022462`6.000000000000008\ \[InvisibleSpace]" dCalculated = \ "\[InvisibleSpace]0.0585873`5.999999999999995\), SequenceForm[ "Bandwidth using DwassAltD Rational for alpha = ", .001, " sampleSize = ", 1000, " desiredPrecision = ", 6, " timeInSeconds = ", .35999999999999965, " actualAlpha = ", 0.00100000031840982265685770808016022462`6.000000000000008, " dCalculated = ", 0.0585873`5.999999999999995], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" sampleSizeByAlpha = "\[InvisibleSpace]{{"n", "alpha", "d", "numDigitsleft", "numDigits", 1, 2, 3, 4, 5, 6, 7, 8}, {500, 0.2`, "0.0397876", \(-1\), 7, "3", "9", "7", "8", "7", "6", 0, 0}, {500, 0.1`, "0.0476515", \(-1\), 7, "4", "7", "6", "5", "1", "5", 0, 0}, {500, 0.05`, "0.0543950", \(-1\), 7, "5", "4", "3", "9", "5", "0", 0, 0}, {500, 0.02`, "0.0622005", \(-1\), 7, "6", "2", "2", "0", "0", "5", 0, 0}, {500, 0.01`, "0.0675094", \(-1\), 7, "6", "7", "5", "0", "9", "4", 0, 0}, {500, 0.001`, "0.0827351", \(-1\), 7, "8", "2", "7", "3", "5", "1", 0, 0}, {1000, 0.2`, "0.0282020", \(-1\), 7, "2", "8", "2", "0", "2", "0", 0, 0}, {1000, 0.1`, "0.0337639", \(-1\), 7, "3", "3", "7", "6", "3", "9", 0, 0}, {1000, 0.05`, "0.0385338", \(-1\), 7, "3", "8", "5", "3", "3", "8", 0, 0}, {1000, 0.02`, "0.0440558", \(-1\), 7, "4", "4", "0", "5", "5", "8", 0, 0}, {1000, 0.01`, "0.0478120", \(-1\), 7, "4", "7", "8", "1", "2", "0", 0, 0}, {1000, 0.001`, "0.0585873", \(-1\), 7, "5", "8", "5", "8", "7", "3", 0, 0}}\), SequenceForm[ " sampleSizeByAlpha = ", {{"n", "alpha", "d", "numDigitsleft", "numDigits", 1, 2, 3, 4, 5, 6, 7, 8}, {500, .20000000000000001, "0.0397876", -1, 7, "3", "9", "7", "8", "7", "6", 0, 0}, { 500, .10000000000000001, "0.0476515", -1, 7, "4", "7", "6", "5", "1", "5", 0, 0}, {500, .050000000000000003, "0.0543950", -1, 7, "5", "4", "3", "9", "5", "0", 0, 0}, {500, .02, "0.0622005", -1, 7, "6", "2", "2", "0", "0", "5", 0, 0}, {500, .01, "0.0675094", -1, 7, "6", "7", "5", "0", "9", "4", 0, 0}, {500, .001, "0.0827351", -1, 7, "8", "2", "7", "3", "5", "1", 0, 0}, {1000, .20000000000000001, "0.0282020", -1, 7, "2", "8", "2", "0", "2", "0", 0, 0}, {1000, .10000000000000001, "0.0337639", -1, 7, "3", "3", "7", "6", "3", "9", 0, 0}, { 1000, .050000000000000003, "0.0385338", -1, 7, "3", "8", "5", "3", "3", "8", 0, 0}, {1000, .02, "0.0440558", -1, 7, "4", "4", "0", "5", "5", "8", 0, 0}, {1000, .01, "0.0478120", -1, 7, "4", "7", "8", "1", "2", "0", 0, 0}, {1000, .001, "0.0585873", -1, 7, "5", "8", "5", "8", "7", "3", 0, 0}}], Editable->False]], "Print"], Cell[BoxData[ \(2\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 18.2 Produce Files of Bandwidths Sample Output File, \ C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.csv\ \>", "Subsection"], Cell["\<\ DwassAltD linear search to find d to desiredPrecision=6 for a specified \ sampleSize and alpha alphaIn,sampleSize,desiredPrecision,timeInSeconds,actualAlpha,d 0.2,500,6,0.031,0.2,0.0397876 0.1,500,6,0.063,0.1,0.0476515 0.05,500,6,0.031,0.0500001,0.054395 0.02,500,6,0.094,0.0200001,0.0622005 0.01,500,6,0.078,0.01,0.0675094 0.001,500,6,0.125,0.000999986,0.0827351 0.2,1000,6,0.156,0.2,0.028202 0.1,1000,6,0.219,0.1,0.0337639 0.05,1000,6,0.219,0.0500001,0.0385338 0.02,1000,6,0.281,0.02,0.0440558 0.01,1000,6,0.265,0.00999995,0.047812 0.001,1000,6,0.36,0.001,0.0585873\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 18.3 Produce Files of Bandwidths Sample Output File, \ C:/KSoutput/KS1SidedOneSampleBandwidthsN500And1000.dat\ \>", "Subsection"], Cell["\<\ n alpha d numDigitsleft numDigits 1 2 3 4 5 6 7 8 500 0.2 0.0397876-1 7 3 9 7 8 7 6 0 0 500 0.1 0.0476515-1 7 4 7 6 5 1 5 0 0 500 0.05 0.0543950-1 7 5 4 3 9 5 0 0 0 500 0.02 0.0622005-1 7 6 2 2 0 0 5 0 0 500 0.01 0.0675094-1 7 6 7 5 0 9 4 0 0 500 0.001 0.0827351-1 7 8 2 7 3 5 1 0 0 1000 0.2 0.0282020-1 7 2 8 2 0 2 0 0 0 1000 0.1 0.0337639-1 7 3 3 7 6 3 9 0 0 1000 0.05 0.0385338-1 7 3 8 5 3 3 8 0 0 1000 0.02 0.0440558-1 7 4 4 0 5 5 8 0 0 1000 0.01 0.0478120-1 7 4 7 8 1 2 0 0 0 1000 0.001 0.0585873-1 7 5 8 5 8 7 3 0 0\ \>", "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["19. Direct Formulae Timings with Sample Intermediate Output", "Section"], Cell["\<\ The following is the code of the Mathematica function \ TimingKS1SidedOneSampleRationalDirectFormulae and sample intermediate output. \ This program reads the data file specified in input variable importFileName \ and then using the bandwidths in this file, constructs bandwidths to rhoin \ digits of precision, determines the computer time needed for all four direct \ formulae (DwassD,DwassAltD,SmirnovD,SmirnovAltD) to calculate the p-value, \ and then outputs these computational times to the file name read into \ variable outputFileName. The output file is delimited by the character in \ the input variable separatorString. If separatorString is a comma, the \ output file can be read into Excel. The input data file specified in input \ variable importFileName is the file produced by the Mathematica function \ KS1SidedOneSampleBandwidthsToFile in section 18. Sample intermediate output \ is given in subsection 19.1. For the intermediate output in subsection 18.1, \ subsection 18.2 contains the input file specified in the variable \ importFileName while subsection 18.3 contains the output file produced with \ the file name contained in the variable: outputFileName. \ \>", "Text"], Cell[BoxData[ \(TimingKS1SidedOneSampleRationalDirectFormulae[importFileName_, \ rnpIn_, \ intermediateOutput_, \ outputFileName_, \ howToOpenFile_, \ separatorString_]\ \ := \ Module[{sampleSize, \ numberSampleSizes, \ alpha, \ numberOFalphas, ssbaIndex, \ ssbaNumberColumns, \ ssbaNumberRows, \ dataVectorDimensions, \ sampleSizeByAlpha, \ outputFileNumber, \ sampleSizeVector, sampleSizeVectorIndex, \ alphaVector, alphaVectorIndex, \ probabilityVector, \ rightTailProbability, \ functionOutput, \ functionTimeString, \ timeString, \ rnp, \ rnpIndex, \ dIn, \ dInVector}, \[IndentingNewLine] (*\ Generate\ KS1Sided\ one\ sample\ timings\ for\ the\ direct\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ formulae\ \(\((\)\(SmirnovD, \ SmirnovAltD, \ DwassD, \ and\)\(\ \)\)*) \[IndentingNewLine] (*\(\(\ \ \ \ \ \ \ \ \ \)\(DwassAltD\)\()\)\)\ and\ put\ into\ file, \ outputFileName\ *) \[IndentingNewLine] (*\ Open\ \(file : \ howToOpenFile\) = 0, \ use\ OpenWrite\ which\ creates\ a\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ new\ file\ and\ destroys\ an\ old\ file\ *) \ \ \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ howToOpenFile = 1, \ use\ OpenAppend\ which\ opens\ file\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ and\ appends\ output\ to\ end\ of\ that\ \(\(file\ \)\(.\)\)\ *) \[IndentingNewLine] (*\ importFileName\ = \ file\ name\ for\ file\ of\ bandwidths\ *) \[IndentingNewLine] (*\ rnpIn\ = \ \(rnp\ = \ rational\ number\ precision\), \ number\ of\ digits\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ of\ \ precision\ for\ each\ bandwidth\ used\ as\ \(\(input\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ For\ each\ sampleSize\ and\ alpha\ combination\ in\ file\ \ *) \[IndentingNewLine] (*\ \ \ \ \ importFileName, \ the\ test\ statistic\ dIn\ is\ constructed\ *) \[IndentingNewLine] \ (*\ \ \ \ \ from\ the\ bandwidth\ to\ rnpIn\ digits\ of\ \(\(precision\)\(.\)\ \)\ *) \[IndentingNewLine] (*\ \ \ \ \ The\ time\ is\ recorded\ in\ file\ \ outputFileName\ for\ each\ *) \[IndentingNewLine] (*\ \ \ \ \ direct\ formula\ \ to\ compute\ the\ right\ tail\ probability\ *) \[IndentingNewLine] (*\ \ \ \ \ \ for\ dIn\ and\ the\ sampleSize\ \(\(outputFileName\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine]rnp\ = \ Floor[rnpIn]; \[IndentingNewLine]sampleSizeByAlpha\ = \ Import[importFileName, \ "\"]; \ \[IndentingNewLine]dataVectorDimensions\ = \ Dimensions[ sampleSizeByAlpha]; \[IndentingNewLine]ssbaNumberRows\ = \ \ \ dataVectorDimensions[\([1]\)]; \[IndentingNewLine]ssbaNumberColumns\ = \ \ \ dataVectorDimensions[\([2]\)]; \[IndentingNewLine]sampleSize\ = \ sampleSizeByAlpha[\([2, 1]\)]; \[IndentingNewLine]numberOFalphas\ = \ 1; \[IndentingNewLine]Do[\[IndentingNewLine]\(If[ sampleSizeByAlpha[\([ssbaIndex, 1]\)]\ \[Equal] \ sampleSize, \ numberOFalphas\ = \ numberOFalphas\ + \ 1];\)\[IndentingNewLine], {ssbaIndex, \ 3, ssbaNumberRows, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]numberSampleSizes\ = \ \ Rationalize[\ \((ssbaNumberRows\ - \ 1)\)/numberOFalphas, \ 0]; \[IndentingNewLine]sampleSizeVector\ = \ Array[0, \ numberSampleSizes]; \[IndentingNewLine]alphaVector\ = \ Array[0, \ numberOFalphas]; \[IndentingNewLine]dInVector\ = \ Array[0, \ numberOFalphas]; \[IndentingNewLine]sampleSizeVectorIndex\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]sampleSizeVectorIndex\ \ = \ sampleSizeVectorIndex\ \ + \ 1; \[IndentingNewLine]sampleSizeVector[\([sampleSizeVectorIndex]\ \)]\ = \ sampleSizeByAlpha[\([ssbaIndex, 1]\)];\[IndentingNewLine], {ssbaIndex, \ 2, ssbaNumberRows, \ numberOFalphas}\[IndentingNewLine]]; \ \[IndentingNewLine]alphaVectorIndex\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]alphaVectorIndex\ = \ alphaVectorIndex\ \ + \ 1; \[IndentingNewLine]alphaVector[\([alphaVectorIndex]\)]\ = \ sampleSizeByAlpha[\([ssbaIndex, 2]\)];\[IndentingNewLine], {ssbaIndex, \ 2, numberOFalphas + 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]probabilityVector\ = \ \ Array[0, \ numberOFalphas]; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ outputFileNumber\ = \ OpenWrite[outputFileName], \ outputFileNumber\ = \ OpenAppend[outputFileName]]; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ \[IndentingNewLine]WriteString[ outputFileNumber, \ "\", \ separatorString, \ separatorString, \ "\"\[IndentingNewLine]\ \ \ \ \ \ \ Journal\ of\ the\ American\ Statistical\ Association\ 67, \ \ \((1972)\), \ pp . \ 591 - 596. \ *) \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]finalNumberTerms\ = \ Floor[Rationalize[sampleSize\ - \ t, \ 0]]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< finalNumberTerms = \>", \ finalNumberTerms]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]e\ \ = \ Array[0, \ {sampleSize}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ \ *) \[IndentingNewLine]OneMINUStOVERn\ = \ Rationalize[1\ - \ t/sampleSize, \ 0]; \[IndentingNewLine]e[\([1]\)]\ = \ Rationalize[\ 1\ - \ OneMINUStOVERn, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< OneMINUStOVERn = \>", \ OneMINUStOVERn, \ "\< e[[1]] = \>", \ e[\([1]\)]\ \ \ ]]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ \ = \ Rationalize[OneMINUStOVERn^k, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ = \ OneMINUStOVERn; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For k = \>", \ k, \ "\< and j = 0 binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((k\ - \ j\ + \ 1)\)\ /\ j, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ \ = \ Rationalize[OneMINUStOVERnMINUSjOVERn\ \ - \ 1/sampleSize, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ OneMINUStOVERnMINUSjOVERn\ ^\((k\ - \ j)\)*\ e[\([j]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For k = \>", \ k, \ "\< and j = \>", \ j, \ "\< binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]];\[IndentingNewLine], {j, \ 1, \ k - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]e[\([k]\)]\ = \ Rationalize[1\ - \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< e[[\>", \ k, \ "\<]] = \>", \ e[\([k]\)]\ \ ]];\[IndentingNewLine], {k, \ 2, \ finalNumberTerms, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]term\ = \ Rationalize[OneMINUStOVERn^sampleSize, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ = \ OneMINUStOVERn; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For sampleSize = \>", \ sampleSize, \ "\< and j = 0 binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]]; \ \[IndentingNewLine]Do[\[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((sampleSize\ - \ j\ + \ 1)\)\ /\ j, \ 0]; \[IndentingNewLine]OneMINUStOVERnMINUSjOVERn\ \ = \ \ Rationalize[OneMINUStOVERnMINUSjOVERn\ \ - \ 1/sampleSize, \ 0]; \[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ OneMINUStOVERnMINUSjOVERn\ ^\((sampleSize\ - \ j)\)*\ e[\([j]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For sampleSize = \>", \ sampleSize, \ "\< and j = \>", \ j, \ "\< binomialCoefficient = \>", \ binomialCoefficient, \ "\< OneMINUStOVERnMINUSjOVERn = \>", \ OneMINUStOVERnMINUSjOVERn, \ "\< term = \>", \ term\ \ ]];\[IndentingNewLine], {j, \ 1, \ finalNumberTerms, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]rightTailProbability\ \ = \ term; \[IndentingNewLine]Label[ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(DanielsKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ \ rightTailProbability, \ i, \ k, \ Q, \ newQvector, \ \ aSUBiMinusOne, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Daniels\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1\ = \ increasing\ amount\ of\ intermediate\ output\ *) \[IndentingNewLine] \ (*\ \ \ \ \ \ \ \ \ \ \ 2\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ Originally\ \ in\ Daniels\ \((1945)\)\ and\ reiterated\ by\ Noe\ and\ Vandewiele\ \ \(\((1968)\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ Formula\ used\ to\ \ implement\ the\ function\ from\ Noe\ and\ Vandewiele\ \(\((1968)\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ both\ \ positive\ and\ negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ H . \ E . \ Daniels\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ \ Proceedings\ of\ the\ Royal\ Statistical\ Society\ Series\ A\ \[IndentingNewLine]\ \ \ \ \ \ 183\ \((1945)\), \ pp . \ 405 - 435. \ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ Statistics\ 39\ \ \((1968)\), \ pp . \ 233 - 241. \ *) \[IndentingNewLine]sampleSize\ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]Q\ \ = \ Array[0, \ {sampleSizePlusOne}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]Q[\([1]\)]\ \ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]Q[\([i + 1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]aSUBiMinusOne\ = \ Rationalize[Max[\((i - t)\)/sampleSize, \ 0]\ - \ 1, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< Start i = \>", \ i, \ "\< aSUBiMinusOne = \>", \ aSUBiMinusOne]]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[\ \(-\ Binomial[i, \ k]\)\ *\ Q[\([k + 1]\)]\ *\ aSUBiMinusOne^\((i - k)\), \ 0]; \[IndentingNewLine]Q[\([i + 1]\)]\ = \ Rationalize[Q[\([i + 1]\)]\ + \ term, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((i\ - \ k)\)\ /\ \((k\ + \ 1)\), \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< k = \>", \ k, \ "\< term = \>", \ term, \ "\< Q[[\>", \ i, "\<]] stored as Q[[\>", \ i + 1, "\<]] = \>", \ Q[\([i + 1]\)]\ ]];\[IndentingNewLine], {k, \ 0, \ i - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< End i = \>", \ i, \ \ "\< Q[[\>", \ i, "\<]] stored as Q[[\>", \ i + 1, "\<]] = \>", \ Q[\([i + 1]\)]\ ]];\[IndentingNewLine], {i, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ Q[\([sampleSizePlusOne]\)]; \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(NoeKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ sampleSizePlusTwo, \ twiceSampleSize, \ rightTailProbability, \ i, \ k, \ m, FgammaSUBmVector, \ \ pSUBmVector, \ oldQvector, \ newQvector, \ alphaNumber, \ betaNumber, \ nextAlphaF, \ nextBetaF, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Noe\ and\ Vandewiele\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ \ Sided\ one\ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ Noe\ later\ added\ a\ \(\(correction\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2, \ 3, \ 4\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 5\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ The\ formula\ containing\ the\ correction\ implemented\ below\ is\ \ from\ *) \[IndentingNewLine]\ (*\ \ \ Shorack\ and\ Wellner, \ page\ 363, \ formulas\ \((24)\)\ through\ \(\((28)\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ only\ non - negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ \[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ Mathematical\ Statistics\ 39\ \ \((1968)\), \ pp . \ 233 - 241. \ *) \[IndentingNewLine] (*\ M . \ Noe\ and\ G . \ Vandewiele\[IndentingNewLine]\ \ \ \ \ "\"\ Annals\ of\ Mathematical\ Statistics\ 43\ \ \((1972)\), \ pp . \ 58 - 64. \ *) \[IndentingNewLine] (*\ G . \ R . \ Shorack\ and\ J . \ A . \ Wellner\[IndentingNewLine]\ \ \ \ \ Empirical\ processes\ with\ \ applications\ to\ statistics, \ \[IndentingNewLine]\ \ \ \ \ \ \(John\ Wiley\ \ &\)\ Sons, \ New\ York\ \(\((1986)\)\(.\)\)\ *) \[IndentingNewLine]sampleSize\ \ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]sampleSizePlusTwo\ = \ Rationalize[\ sampleSizePlusOne\ + \ 1, \ 0]; \[IndentingNewLine]twiceSampleSize\ = \ Rationalize[2\ *\ sampleSize, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne, \ "\< sampleSizePlusTwo = \>", \ sampleSizePlusTwo, \ "\< twiceSampleSize = \>", \ twiceSampleSize]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]oldQvector\ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]newQvector\ \ \ = \ Array[ 0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]FgammaSUBmVector\ \ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine]pSUBmVector\ \ = \ Array[0, \ {sampleSizePlusTwo}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]nextAlphaF\ \ = \ Rationalize[\ Max[\((1\ - \ t)\)/sampleSize, \ 0], 0]; \[IndentingNewLine]FgammaSUBmVector[\([1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]pSUBmVector[\([1]\)]\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]FgammaSUBmVector[\([\ m]\)]\ = \ Rationalize[\ Max[\((m\ - \ 1\ - \ t)\)/sampleSize, \ 0], 0]; \[IndentingNewLine]pSUBmVector[\([m]\)]\ = \ Rationalize[ FgammaSUBmVector[\([m]\)]\ - \ FgammaSUBmVector[\([m - 1]\)], \ 0];\[IndentingNewLine], {m, \ 2, \ sampleSizePlusOne, \ 1}\[IndentingNewLine]]; \ \[IndentingNewLine]FgammaSUBmVector[\([sampleSizePlusTwo]\)]\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]pSUBmVector[\([sampleSizePlusTwo]\)]\ = \ Rationalize[1\ - \ FgammaSUBmVector[\([sampleSizePlusOne]\)], \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< FgammaSUBmVector = \>", \ FgammaSUBmVector]\ ]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< pSUBmVector = \>", \ pSUBmVector]\ ]; \[IndentingNewLine] (*\ Begin\ the\ recursion\ *) \[IndentingNewLine]oldQvector[\([1]\)]\ \ = \ 1; \[IndentingNewLine]oldQvector[\([2]\)]\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< m = \>", \ m]\ ]; \[IndentingNewLine]Do[\[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< i = \>", \ i]\ ]; \[IndentingNewLine]newQvector[\([i\ + \ 1]\)]\ = \ 0; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[oldQvector[\([k\ + \ 1]\)], \ 0]; \[IndentingNewLine]If[ i\ > \ k, \ \ term\ = \ Rationalize[ term\ *\ Binomial[i, \ k]\ *\ \ \ pSUBmVector[\([m + 1]\)]^\((i\ - \ k)\), \ 0]\ ]; \[IndentingNewLine]newQvector[\([i\ + \ 1]\)]\ = \ Rationalize[newQvector[\([i\ + \ 1]\)]\ + \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 5, \ Print["\< k = \>", \ k, \ "\< Binomial[i, k] = \>", \ binomialCoefficient, \ "\< oldQvector[[k + 1]] = \>", oldQvector[\([k\ + \ 1]\)], \ "\< pSUBmVector[[m+1]] = \>", \ pSUBmVector[\([m + 1]\)]\ ]\ ]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< k = \>", \ k, \ "\< term = \>", \ term, \ "\< newQvector[[\>", i, \ "\<]] stored as newQvector[[\>", \ i + 1, "\<]] = \>", \ newQvector[\([i\ + \ 1]\)]\ ]\ ]; \[IndentingNewLine]binomialCoefficient\ \ = \ Rationalize[binomialCoefficient\ *\ \((i\ - \ k)\)\ /\ \((k\ + \ 1)\), \ 0];\[IndentingNewLine], {k, \ 0, \ i, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< newQvector[[\>", \ i, "\<]] stored as newQvector[[\>", \ i + 1, \ "\<]] = \>", \ newQvector[\([i\ + \ 1]\)]]\ ];\[IndentingNewLine], {i, \ 0, \ \ m - 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]newQvector[\([m + 1]\)]\ = \ Rationalize[0, 0]; \[IndentingNewLine]oldQvector\ = \ newQvector;\[IndentingNewLine], {m, \ 1, \ sampleSizePlusOne, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ newQvector[\([sampleSizePlusOne]\)]; \ \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[BoxData[ \(SteckKS1SidedRTProbRational[tIn_, \ internalPrecisionIn_, \ \ sampleSizeIn_, \ intermediateOutput_]\ := \ Module[{t, \ internalPrecision, \ sampleSize, \ sampleSizePlusOne, \ \ rightTailProbability, \ i, \ j, \ m, \ b, \ P, \ binomialCoefficient, \ term, \ \ leftTailProbability}, \[IndentingNewLine] (*\ Steck\ recursion\ formula\ to\ calculate\ the\ KS\ 1\ Sided\ one\ \ sample\ *) \[IndentingNewLine] (*\ \ \ \ right\ tail\ p - value\ for\ sample\ size\ sampleSizeIn\ and\ \ *) \[IndentingNewLine] (*\ \ \ \ test\ statistic\ tIn/ sampleSizeIn\ using\ rational\ \(\(arithmetic\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, \ 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ internalPrecision\ - \ for\ a\ rational\ number\ output\ in\ decimal\ form\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ during\ intermediate\ output, \ the\ number\ of\ decimal\ digits\ in\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ the\ printed\ output\ *) \[IndentingNewLine] (*\ \ \ \ Formula\ \ used\ to\ implement\ the\ function\ from\ Shorack\ and\ Wellner\ \(\((1986)\)\ \(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ This\ recursion\ formula\ has\ both\ \ positive\ and\ negative\ \(\(terms\)\(.\)\)\ *) \[IndentingNewLine] (*\ G . \ P . \ Steck\[IndentingNewLine]\ \ \ \ \ "\"\[IndentingNewLine]\ \ \ \ \ \ Annals\ of\ \ Mathematical\ Statistics\ 40, \ \((1969)\), \ pp . \ 1449 - 1466. \ *) \[IndentingNewLine] (*\ G . \ R . \ Shorack\ and\ J . \ A . \ Wellner\[IndentingNewLine]\ \ \ \ \ Empirical\ processes\ with\ \ applications\ to\ statistics, \ \[IndentingNewLine]\ \ \ \ \ \ \(John\ Wiley\ \ &\)\ Sons, \ New\ York\ \(\((1986)\)\(.\)\)\ *) \[IndentingNewLine]sampleSize\ \ = \ Floor[sampleSizeIn]; \[IndentingNewLine]sampleSizePlusOne\ = \ Rationalize[\ sampleSize\ + \ 1, \ 0]; \[IndentingNewLine]t\ = \ Rationalize[tIn, \ 0]; \[IndentingNewLine]internalPrecision\ = \ Floor[internalPrecisionIn]; \[IndentingNewLine]rightTailProbability\ \ = \ \(-99\); \[IndentingNewLine] (*\ Check\ for\ sampleSize\ reasonableness\ *) \[IndentingNewLine]If[ sampleSize\ < \ 2, \ Print["\", \ sampleSize, \ "\< is too small.\>"]; \ Goto[ExitNow]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\", \ sampleSize, \ "\< tIn = \>", \ tIn, \ "\< t = \>", \ t, \ "\< sampleSizePlusOne = \>", \ sampleSizePlusOne]]; \[IndentingNewLine] (*\ Check\ for\ reasonableness\ of\ t\ *) \[IndentingNewLine]If[ t\ \[LessEqual] \ 1/2, \ rightTailProbability\ = \ 1; \ Goto[ExitNow]]; \[IndentingNewLine]If[ t\ \[GreaterEqual] \ sampleSize, \ rightTailProbability\ = \ 0; \ Goto[ExitNow]]; \[IndentingNewLine] (*\ Declare\ all\ vectors\ *) \[IndentingNewLine]P\ \ = \ Array[0, \ {sampleSizePlusOne}]; \[IndentingNewLine]b\ = \ Array[0, \ {sampleSize}]; \[IndentingNewLine] (*\ Construct\ the\ initial\ vectors\ *) \[IndentingNewLine]P[\([1]\)]\ \ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]b[\([j]\)]\ = \ Rationalize[Min[\((j\ - \ 1\ + \ t)\)/sampleSize, \ 1], \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< b[[\>", \ j, \ "\<]] = \>", \ b[\([j]\)]\ \ ]];\[IndentingNewLine], {j, \ 1, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< b = \>", \ b\ ]]; \[IndentingNewLine]P[\([2]\)]\ = \ Rationalize[b[\([1]\)], \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[0, \ 0]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[1, \ 0]; \[IndentingNewLine]Do[\[IndentingNewLine]term\ = \ Rationalize[ term\ + \ binomialCoefficient\ *\ \((b[\([i]\)]\ - \ b[\([m + 1]\)])\)^\((i - m)\)*\ P[\([m + 1]\)]\ , \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 3, \ Print["\< For i = \>", \ i, \ "\< and m = \>", \ m, \ "\< term = \>", \ term\ \ ]]; \[IndentingNewLine]binomialCoefficient\ = \ Rationalize[ binomialCoefficient\ *\ \((i\ - \ m)\)\ /\ \((m\ + \ 1)\), \ 0];\[IndentingNewLine], {m, \ 0, \ i - 2, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]P[\([i + 1]\)]\ = \ Rationalize[b[\([i]\)]^i\ - \ term, \ 0]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 2, \ Print["\< P[[\>", \ i, \ "\<]] stored as P[[\>", \ i + 1, \ "\<]] = \>", \ P[\([i + 1]\)]\ \ ]];\[IndentingNewLine], {i, \ 2, \ sampleSize, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]leftTailProbability\ \ = \ P[\([sampleSizePlusOne]\)]; \[IndentingNewLine]rightTailProbability\ = \ 1\ - \ leftTailProbability; \[IndentingNewLine]Label[ ExitNow]; \[IndentingNewLine]If[ intermediateOutput\ \[GreaterEqual] \ 1, \ Print["\< rightTailProbability = \>", \ rightTailProbability]]; \[IndentingNewLine]rightTailProbability\ \[IndentingNewLine]]\)], "Input"], Cell[CellGroupData[{ Cell["\<\ 21.1 Recursion Formulae and DwassAltD Timings Sample Intermediate Output\ \>", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(TimingKS1SidedRecursionFormulaeDwassAltD["\", \ 3, \ 3, \ "\", \ 0, \ "\<,\>"]\)], "Input"], Cell[BoxData[ InterpretationBox[\("KS1Sided TimingKS1SidedRecursionFormulaeDwassAltD: \ importFileName = \ "\[InvisibleSpace]"C:/KSoutput/KS1SidedOneSampleBandwidthsN50And100.dat"\ \[InvisibleSpace]" outputFileName = \ "\[InvisibleSpace]"C:/KSoutput/\ RecursionFormulaeDwassAltDRationalTimesN50And100ByAlpha.csv"\[InvisibleSpace]\ ", howToOpenFile = "\[InvisibleSpace]0\[InvisibleSpace]", separatorString = \ '"\[InvisibleSpace]","\[InvisibleSpace]"'"\[InvisibleSpace]", \ sampleSizeVector = "\[InvisibleSpace]{50, 100}\[InvisibleSpace]" with "\[InvisibleSpace]2\[InvisibleSpace]" \ sampleSizes, and alphaVector = "\[InvisibleSpace]{0.2`, 0.1`, 0.05`, 0.02`, 0.01`, 0.001`}\[InvisibleSpace]" with "\[InvisibleSpace]6\ \[InvisibleSpace]" alpha's"\[InvisibleSpace]" rnp = "\[InvisibleSpace]3\), SequenceForm[ "KS1Sided TimingKS1SidedRecursionFormulaeDwassAltD: importFileName = \ ", "C:/KSoutput/KS1SidedOneSampleBandwidthsN50And100.dat", " outputFileName = ", "C:/KSoutput/RecursionFormulaeDwassAltDRationalTimesN50And100ByAlpha.\ csv", ", howToOpenFile = ", 0, ", separatorString = '", ",", "'", ", sampleSizeVector = ", {50, 100}, " with ", 2, " sampleSizes, and alphaVector = ", {.20000000000000001, \ .10000000000000001, .050000000000000003, .02, .01, .001}, " with ", 6, " alpha's", " rnp = ", 3], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" sampleSizeByAlpha = "\[InvisibleSpace]{{"n", "alpha", "d", "numDigitsleft", "numDigits", 1, 2, 3, 4, 5, 6, 7, 8}, {50, 0.2`, 0.12363`, 0, 6, 1, 2, 3, 6, 3, 0, 0, 0}, {50, 0.1`, 0.148398`, 0, 6, 1, 4, 8, 3, 9, 8, 0, 0}, {50, 0.05`, 0.169594`, 0, 6, 1, 6, 9, 5, 9, 4, 0, 0}, {50, 0.02`, 0.19407`, 0, 6, 1, 9, 4, 0, 7, 0, 0, 0}, {50, 0.01`, 0.210677`, 0, 6, 2, 1, 0, 6, 7, 7, 0, 0}, {50, 0.001`, 0.258089`, 0, 6, 2, 5, 8, 0, 8, 9, 0, 0}, {100, 0.2`, 0.0880746`, \(-1\), 7, 8, 8, 0, 7, 4, 6, 0, 0}, {100, 0.1`, 0.105627`, 0, 6, 1, 0, 5, 6, 2, 7, 0, 0}, {100, 0.05`, 0.120666`, 0, 6, 1, 2, 0, 6, 6, 6, 0, 0}, {100, 0.02`, 0.138054`, 0, 6, 1, 3, 8, 0, 5, 4, 0, 0}, {100, 0.01`, 0.149868`, 0, 6, 1, 4, 9, 8, 6, 8, 0, 0}, {100, 0.001`, 0.183683`, 0, 6, 1, 8, 3, 6, 8, 3, 0, 0}}\), SequenceForm[ " sampleSizeByAlpha = ", {{"n", "alpha", "d", "numDigitsleft", "numDigits", 1, 2, 3, 4, 5, 6, 7, 8}, {50, .20000000000000001, .12363, 0, 6, 1, 2, 3, 6, 3, 0, 0, 0}, {50, .10000000000000001, .148398, 0, 6, 1, 4, 8, 3, 9, 8, 0, 0}, { 50, .050000000000000003, .16959399999999999, 0, 6, 1, 6, 9, 5, 9, 4, 0, 0}, {50, .02, .19406999999999999, 0, 6, 1, 9, 4, 0, 7, 0, 0, 0}, { 50, .01, .210677, 0, 6, 2, 1, 0, 6, 7, 7, 0, 0}, { 50, .001, .25808900000000001, 0, 6, 2, 5, 8, 0, 8, 9, 0, 0}, { 100, .20000000000000001, .088074600000000003, -1, 7, 8, 8, 0, 7, 4, 6, 0, 0}, {100, .10000000000000001, .105627, 0, 6, 1, 0, 5, 6, 2, 7, 0, 0}, {100, .050000000000000003, .120666, 0, 6, 1, 2, 0, 6, 6, 6, 0, 0}, {100, .02, .13805400000000001, 0, 6, 1, 3, 8, 0, 5, 4, 0, 0}, { 100, .01, .149868, 0, 6, 1, 4, 9, 8, 6, 8, 0, 0}, { 100, .001, .18368300000000001, 0, 6, 1, 8, 3, 6, 8, 3, 0, 0}}], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" ssbaNumberRows = "\[InvisibleSpace]13\ \[InvisibleSpace]" ssbaNumberColumns = "\[InvisibleSpace]13\), SequenceForm[ " ssbaNumberRows = ", 13, " ssbaNumberColumns = ", 13], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" sampleSizeByAlpha[[2,1]] = "\[InvisibleSpace]50\ \[InvisibleSpace]" sampleSizeByAlpha[[2,2]] = "\[InvisibleSpace]0.2`\ \[InvisibleSpace]" sampleSizeByAlpha[[2,3]] = "\[InvisibleSpace]0.12363`\ \[InvisibleSpace]" sampleSizeByAlpha[[2,4]] = "\[InvisibleSpace]0\ \[InvisibleSpace]" sampleSizeByAlpha[[2,5]] = "\[InvisibleSpace]6\ \[InvisibleSpace]" sampleSizeByAlpha[[2,6]] = "\[InvisibleSpace]1\ \[InvisibleSpace]" sampleSizeByAlpha[[2,7]] = "\[InvisibleSpace]2\), SequenceForm[ " sampleSizeByAlpha[[2,1]] = ", 50, " sampleSizeByAlpha[[2,2]] = ", .20000000000000001, " sampleSizeByAlpha[[2,3]] = ", .12363, " sampleSizeByAlpha[[2,4]] = ", 0, " sampleSizeByAlpha[[2,5]] = ", 6, " sampleSizeByAlpha[[2,6]] = ", 1, " sampleSizeByAlpha[[2,7]] = ", 2], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.046999999999999986`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", .046999999999999986], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.063`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", .063], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999993`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", .046999999999999931], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04700000000000004`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", .047000000000000042], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.062000000000000055`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", .062000000000000055], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999993`\), SequenceForm[ " Daniels for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", .046999999999999931], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.797`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", .79700000000000004], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.8279999999999998`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", .82799999999999985], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.7970000000000002`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", .79700000000000015], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.8119999999999998`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", .81199999999999983], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.8130000000000002`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", .81300000000000017], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.8120000000000003`\), SequenceForm[ " Noe for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", .81200000000000028], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.0470000000000006`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", .047000000000000597], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.031000000000000583`\), SequenceForm[ " Steck for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", .031000000000000583], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.0470000000000006`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", .047000000000000597], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.04699999999999971`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", .046999999999999709], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.0470000000000006`\), SequenceForm[ " Bolshev for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", .047000000000000597], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.031000000000000583`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", .031000000000000583], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.03200000000000003`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", .032000000000000028], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.030999999999999694`\), SequenceForm[ " Conover for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", .030999999999999694], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.124`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19812105360763934647564946942406107326`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .20000000000000001, " dIn = ", .124, " rightTailProbability = ", 0.19812105360763934647564946942406107326`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.148`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.10122081374974531231873934997735595842`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .10000000000000001, " dIn = ", .14799999999999999, " rightTailProbability = ", 0.10122081374974531231873934997735595842`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.17`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04929657837165489352980418364578579705`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .050000000000000003, " dIn = ", .17000000000000001, " rightTailProbability = ", 0.04929657837165489352980418364578579705`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.194`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02005637118911880543070892201775643058`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .02, " dIn = ", .19400000000000001, " rightTailProbability = ", 0.02005637118911880543070892201775643058`9.999999999999998, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.211`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00986019341051355911204779311366855166`9.999999999999998\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .01, " dIn = ", .21099999999999999, " rightTailProbability = ", 0.00986019341051355911204779311366855166`9.999999999999998, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]50\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.258`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00100476345878945439903601681198031762`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 50, " for alpha = ", .001, " dIn = ", .25800000000000001, " rightTailProbability = ", 0.00100476345878945439903601681198031762`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.3440000000000003`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", .34400000000000031], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.2809999999999997`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", .28099999999999969], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.2970000000000006`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", .2970000000000006], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.266`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", .26600000000000001], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.23399999999999999`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", .23399999999999999], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Daniels for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.2809999999999997`\), SequenceForm[ " Daniels for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", .28099999999999969], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.766`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", 7.766], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.764999999999999`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", 7.7649999999999988], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.766000000000002`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", 7.7660000000000018], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.547000000000001`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", 7.5470000000000006], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.25`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", 7.25], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Noe for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]7.577999999999996`\), SequenceForm[ " Noe for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", 7.5779999999999959], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.26600000000000534`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", .26600000000000534], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.21799999999999642`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", .21799999999999642], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.23400000000000176`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", .23400000000000176], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.20400000000000063`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", .20400000000000063], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.20300000000000296`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", .20300000000000296], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Steck for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.21799999999999642`\), SequenceForm[ " Steck for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", .21799999999999642], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.29700000000000415`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", .29700000000000415], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.2189999999999941`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", .21899999999999409], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.23400000000000176`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", .23400000000000176], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.23499999999999943`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", .23499999999999943], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.20300000000000296`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", .20300000000000296], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Bolshev for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.2190000000000012`\), SequenceForm[ " Bolshev for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", .21900000000000119], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.23399999999999466`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", .23399999999999466], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.1880000000000024`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", .18800000000000239], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.20300000000000296`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", .20300000000000296], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.1869999999999976`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", .18699999999999761], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.14099999999999824`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", .14099999999999824], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" Conover for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.14000000000000057`\), SequenceForm[ " Conover for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", .14000000000000057], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.2`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.0881`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.19981716615432183292091152242880833744`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .20000000000000001, " dIn = ", .088099999999999998, " rightTailProbability = ", 0.19981716615432183292091152242880833744`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.1`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.106`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.09840604744121765247633435070851236906`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .10000000000000001, " dIn = ", .106, " rightTailProbability = ", 0.09840604744121765247633435070851236906`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.05`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.121`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.04918404798905176093376011712493955826`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .050000000000000003, " dIn = ", .121, " rightTailProbability = ", 0.04918404798905176093376011712493955826`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.02`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.138`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.02006105587659998211823291718431630504`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .02, " dIn = ", .13800000000000001, " rightTailProbability = ", 0.02006105587659998211823291718431630504`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.01`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.15`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.00991962841330852096750374815456516348`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .01, " dIn = ", .14999999999999999, " rightTailProbability = ", 0.00991962841330852096750374815456516348`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ InterpretationBox[\(" DwassAltD for sampleSize = "\[InvisibleSpace]100\ \[InvisibleSpace]" for alpha = "\[InvisibleSpace]0.001`\[InvisibleSpace]" \ dIn = "\[InvisibleSpace]0.184`\[InvisibleSpace]" rightTailProbability = "\ \[InvisibleSpace]0.0009764575067669865040905615259947099`10.000000000000004\ \[InvisibleSpace]" timeInSeconds = "\[InvisibleSpace]0.`\), SequenceForm[ " DwassAltD for sampleSize = ", 100, " for alpha = ", .001, " dIn = ", .184, " rightTailProbability = ", 0.0009764575067669865040905615259947099`10.000000000000004, " timeInSeconds = ", 0.0], Editable->False]], "Print"], Cell[BoxData[ \(2\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 21.2 Recursion Formulae and DwassAltD Timings Sample Input File, \ C:/KSoutput/KS1SidedOneSampleBandwidthsN50And100.dat\ \>", "Subsection"], Cell[BoxData[{ \(n\ alpha\ d\ numDigitsleft\ numDigits\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\), "\n", \(50\ 0.2\ 0.123630\ 0\ 6\ 1\ 2\ 3\ 6\ 3\ 0\ 0\ 0\), "\n", \(50\ 0.1\ 0.148398\ 0\ 6\ 1\ 4\ 8\ 3\ 9\ 8\ 0\ 0\), "\n", \(50\ 0.05\ 0.169594\ 0\ 6\ 1\ 6\ 9\ 5\ 9\ 4\ 0\ 0\), "\n", \(50\ 0.02\ 0.194070\ 0\ 6\ 1\ 9\ 4\ 0\ 7\ 0\ 0\ 0\), "\n", \(50\ 0.01\ 0.210677\ 0\ 6\ 2\ 1\ 0\ 6\ 7\ 7\ 0\ 0\), "\n", \(50\ 0.001\ 0.258089\ 0\ 6\ 2\ 5\ 8\ 0\ 8\ 9\ 0\ 0\), "\n", \(100\ 0.2\ 0.0880746 - 1\ 7\ 8\ 8\ 0\ 7\ 4\ 6\ 0\ 0\), "\n", \(100\ 0.1\ 0.105627\ 0\ 6\ 1\ 0\ 5\ 6\ 2\ 7\ 0\ 0\), "\n", \(100\ 0.05\ 0.120666\ 0\ 6\ 1\ 2\ 0\ 6\ 6\ 6\ 0\ 0\), "\n", \(100\ 0.02\ 0.138054\ 0\ 6\ 1\ 3\ 8\ 0\ 5\ 4\ 0\ 0\), "\n", \(100\ 0.01\ 0.149868\ 0\ 6\ 1\ 4\ 9\ 8\ 6\ 8\ 0\ 0\), "\n", \(100\ 0.001\ 0.183683\ 0\ 6\ 1\ 8\ 3\ 6\ 8\ 3\ 0\ 0\), "\n", \(\)}], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 21.3 Recursion Formulae and DwassAltD Timings Sample Output File, \ C:/KSoutput/RecursionFormulaeDwassAltDRationalTimesN50And100ByAlpha.csv\ \>", "Subsection"], Cell[BoxData[{ \(Sample, , Time\ In\ Seconds\ To\ Compute\ KS1Sided\ P \((\(\(D\)\(+\)\)\ \ \[GreaterEqual] d)\)\ for\ a\ d\ with\ rnp = \(3\ that\ yields\ P \((\(\(D\)\(+\)\ \)\ \[GreaterEqual] d)\) = alpha\ Using\ Rational\ Arithmetic\)\), "\n", \(Size\ n, Method, alpha = 0.2, alpha = 0.1, alpha = 0.05, alpha = 0.02, alpha = 0.01, alpha = 0.001\), "\n", \(50, Daniels, 0.062, 0.063, 0.046, 0.063, 0.047, 0.078\), "\n", \(50, Noe, 0.891, 0.906, 0.875, 0.906, 0.891, 0.906\), "\n", \(50, Steck, 0.062, 0.047, 0.063, 0.062, 0.047, 0.047\), "\n", \(50, Bolshev, 0.047, 0.062, 0.047, 0.047, 0.047, 0.047\), "\n", \(50, Conover, 0.031, 0.047, 0.031, 0.047, 0.031, 0.032\), "\n", \(50, DwassAltD, 0. , 0. , 0. , 0. , 0. , 0. \), "\n", \(100, Daniels, 0.375, 0.312, 0.313, 0.297, 0.265, 0.297\), "\n", \(100, Noe, 8.516, 8.234, 8.375, 8.281, 8.078, 8.188\), "\n", \(100, Steck, 0.297, 0.25, 0.25, 0.265, 0.219, 0.235\), "\n", \(100, Bolshev, 0.296, 0.282, 0.281, 0.25, 0.219, 0.265\), "\n", \(100, Conover, 0.266, 0.203, 0.203, 0.188, 0.156, 0.187\), "\n", \(100, DwassAltD, 0. , 0. , 0. , 0. , 0. , 0. \), "\n", \(\)}], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 22. Rational Number Precision Timings for Direct Formulae with Sample \ Intermediate Output\ \>", "Section"], Cell[TextData[{ "The following is the code of the ", StyleBox["Mathematica", FontSlant->"Italic"], " function TimingKS1SidedRecursionFormulaeDwassAltD and sample intermediate \ output. This program reads the data file specified in input variable \ importFileName and then using the bandwidths in this file, constructs \ bandwidths to rhoin digits of precision, determines the computer time needed \ for all five recursion formulae and DwassAltD with RNIC to calculate the \ p-value, and then outputs these computational times to the file name \ specified in input variable outputFileName. The output file is delimited by \ the character in the input variable separatorString. If separatorString is \ a comma,the output file can be read into Excel. The input data file \ specified in input variable importFileName is the file produced by the \ Mathematica function KS1SidedOneSampleBandwidthsToFile in section 18. Sample \ intermediate output is given in subsection 22.1. For the intermediate output \ in subsection 22.1, subsection 22.2 contains the input file specified in the \ variable importFileName while subsection 22.3 contains the output file \ produced with the file name contained in the variable: outputFileName." }], "Text"], Cell[BoxData[ \(TimingKS1SidedOneSampleRationalDirectFormulaeBYrnpForAlpha[ importFileName_, \ rnpIn_, \ numberOfChosenAlphaIn_, \ intermediateOutput_, \ outputFileName_, \ howToOpenFile_, \ separatorString_]\ \ := \ Module[{sampleSize, \ numberSampleSizes, \ alpha, \ numberOFalphas, ssbaIndex, \ ssbaNumberColumns, \ ssbaNumberRows, \ dataVectorDimensions, \ sampleSizeByAlpha, \ outputFileNumber, \ sampleSizeVector, sampleSizeVectorIndex, \ alphaVector, alphaVectorIndex, \ probabilityVector, \ rightTailProbability, \ functionOutput, \ functionTimeString, \ timeString, \ rnp, \ rnpIndex, \ rnpVector, \ rnpVectorIndex, \ numberOFrnps, \ numberOfChosenAlpha, \ dIn, \ dInVector}, \[IndentingNewLine] (*\ Generate\ KS1Sided\ one\ sample\ timings\ for\ the\ direct\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ formulae\ \(\((\)\(SmirnovD, \ SmirnovAltD, \ DwassD, \ and\)\(\ \)\)*) \[IndentingNewLine] (*\(\(\ \ \ \ \ \ \ \ \ \)\(DwassAltD\)\()\)\)\ and\ put\ into\ file, \ outputFileName\ *) \[IndentingNewLine] (*\ Open\ \(file : \ howToOpenFile\) = 0, \ use\ OpenWrite\ which\ creates\ a\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ new\ file\ and\ destroys\ an\ old\ file\ *) \ \ \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ howToOpenFile = 1, \ use\ OpenAppend\ which\ opens\ file\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ and\ appends\ output\ to\ end\ of\ that\ \(\(file\ \)\(.\)\)\ *) \[IndentingNewLine] (*\ importFileName\ = \ file\ name\ for\ file\ of\ bandwidths\ *) \[IndentingNewLine] (*\ numberOfChosenAlphaIn\ = \ the\ index\ number\ of\ the\ one\ alpha\ *) \[IndentingNewLine] \ (*\ \ \ \ \ \ chosen\ to\ use\ in\ the\ list\ of\ alpha' s\ in\ the\ file\ of\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ bandwidths, \ \(\(importFileName\)\(.\)\)\ *) \[IndentingNewLine] (*\ rnp\ = \ rational\ number\ precision, \ the\ number\ of\ digits\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ of\ precision\ for\ each\ bandwidth\ used\ as\ \(\(input\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ rnpIn\ = \ a\ vector\ of\ rnp' \(\(s\)\(.\)\)\ \ *) \[IndentingNewLine] (*\ For\ each\ sampleSize\ in\ file\ importFileName, \ a\ bandwidth\ *) \[IndentingNewLine] (*\ \ \ \ \ dIn\ is\ \ constructed\ for\ the\ chosen\ alpha\ and\ every\ rnp\ *) \[IndentingNewLine] \ (*\ \ \ \ \ in\ the\ vector\ rnpIn\ with\ rnp\ digits\ of\ \(\(precision\)\(.\ \)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ The\ time\ is\ recorded\ in\ file\ \ outputFileName\ for\ each\ *) \[IndentingNewLine] (*\ \ \ \ \ direct\ formula\ \ to\ compute\ the\ right\ tail\ probability\ *) \[IndentingNewLine] (*\ \ \ \ \ \ for\ dIn\ and\ the\ \(\(sampleSize\)\(.\)\)\ *) \[IndentingNewLine] (*\ intermediateOutput\ - \ the\ amount\ of\ detail\ \((intermediate\ output)\)\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ printed\ during\ the\ execution\ of\ \ the\ \(\(function\)\(.\)\)\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 0\ \ = \ no\ intermediate\ output\ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ \ 1, 2\ = \ increasing\ amounts\ of\ intermediate\ output\ \ *) \[IndentingNewLine] (*\ \ \ \ \ \ \ \ \ \ \ 3\ = \ maximum\ intermediate\ output\ \ *) \[IndentingNewLine]sampleSizeByAlpha\ = \ Import[importFileName, \ "\"]; \ \[IndentingNewLine]dataVectorDimensions\ = \ Dimensions[ sampleSizeByAlpha]; \[IndentingNewLine]ssbaNumberRows\ = \ \ \ dataVectorDimensions[\([1]\)]; \[IndentingNewLine]ssbaNumberColumns\ = \ \ \ dataVectorDimensions[\([2]\)]; \[IndentingNewLine]sampleSize\ = \ sampleSizeByAlpha[\([2, 1]\)]; \[IndentingNewLine]numberOFalphas\ = \ 1; \[IndentingNewLine]Do[\[IndentingNewLine]\(If[ sampleSizeByAlpha[\([ssbaIndex, 1]\)]\ \[Equal] \ sampleSize, \ numberOFalphas\ = \ numberOFalphas\ + \ 1];\)\[IndentingNewLine], {ssbaIndex, \ 3, ssbaNumberRows, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]numberSampleSizes\ = \ \ Rationalize[\ \((ssbaNumberRows\ - \ 1)\)/numberOFalphas, \ 0]; \[IndentingNewLine]sampleSizeVector\ = \ Array[0, \ numberSampleSizes]; \[IndentingNewLine]alphaVector\ = \ Array[0, \ numberOFalphas]; \[IndentingNewLine]dInVector\ = \ Array[0, \ numberOFalphas]; \[IndentingNewLine]sampleSizeVectorIndex\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]sampleSizeVectorIndex\ \ = \ sampleSizeVectorIndex\ \ + \ 1; \[IndentingNewLine]sampleSizeVector[\([sampleSizeVectorIndex]\ \)]\ = \ sampleSizeByAlpha[\([ssbaIndex, 1]\)];\[IndentingNewLine], {ssbaIndex, \ 2, ssbaNumberRows, \ numberOFalphas}\[IndentingNewLine]]; \ \[IndentingNewLine]alphaVectorIndex\ = \ 0; \[IndentingNewLine]Do[\[IndentingNewLine]alphaVectorIndex\ = \ alphaVectorIndex\ \ + \ 1; \[IndentingNewLine]alphaVector[\([alphaVectorIndex]\)]\ = \ sampleSizeByAlpha[\([ssbaIndex, 2]\)];\[IndentingNewLine], {ssbaIndex, \ 2, numberOFalphas + 1, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]numberOfChosenAlpha\ \ = \ Floor[numberOfChosenAlphaIn]; \[IndentingNewLine]If[ numberOfChosenAlpha\ < \ 1, \ numberOfChosenAlpha\ = \ 1]; \[IndentingNewLine]If[ numberOfChosenAlpha\ > \ numberOFalphas, \ numberOfChosenAlpha\ = \ numberOFalphas]; \[IndentingNewLine]alpha\ = \ alphaVector[\([numberOfChosenAlpha]\)]; \ \[IndentingNewLine]dataVectorDimensions\ = \ Dimensions[ rnpIn]; \[IndentingNewLine]numberOFrnps\ = \ \ \ dataVectorDimensions[\([1]\)]; \[IndentingNewLine]rnpVector\ = \ rnpIn; \[IndentingNewLine]Do[\[IndentingNewLine]\ rnpVector[\([\ rnpVectorIndex]\)]\ = \ Floor[rnpIn[\([\ rnpVectorIndex]\)]]; \[IndentingNewLine]If[\ rnpVector[\([\ rnpVectorIndex]\)]\ < \ 1, \ \ rnpVector[\([\ rnpVectorIndex]\)]\ = \ 1]; \[IndentingNewLine]If[\ rnpVector[\([\ rnpVectorIndex]\)]\ > \ ssbaNumberColumns - 6, \ \ rnpVector[\([\ rnpVectorIndex]\)]\ = \ ssbaNumberColumns - 6];\[IndentingNewLine], {\ rnpVectorIndex, \ 1, numberOFrnps, \ 1}\[IndentingNewLine]]; \[IndentingNewLine]probabilityVector\ = \ \ Array[0, \ numberOFrnps]; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ outputFileNumber\ = \ OpenWrite[outputFileName], \ outputFileNumber\ = \ OpenAppend[outputFileName]]; \[IndentingNewLine]If[ howToOpenFile\ \[LessEqual] \ 0, \ \[IndentingNewLine]WriteString[ outputFileNumber, \ "\", \ separatorString, \ separatorString, \ "\