Improve TMath::KolmogorovTest (Jason Detwiler) // //  Method Improvement by Jason A Detwiler (JADetwiler@lbl.gov) //  ----------------------------------------------------------- //   The nuts-and-bolts of the TMath::KolmogorovTest() algorithm is a for-loop //   over the two sorted arrays a and b representing empirical distribution //   functions. The for-loop handles 3 cases: when the next points to be  //   evaluated satisfy a>b, a<b, or a=b: //     //      for (Int_t i=0;i<na+nb;i++) { //         if (a[ia-1] < b[ib-1]) { //            rdiff -= sa; //            ia++; //            if (ia > na) {ok = kTRUE; break;} //         } else if (a[ia-1] > b[ib-1]) { //            rdiff += sb; //            ib++; //            if (ib > nb) {ok = kTRUE; break;} //         } else { //            rdiff += sb - sa; //            ia++; //            ib++; //            if (ia > na) {ok = kTRUE; break;} //            if (ib > nb) {ok = kTRUE; break;} //        } //         rdmax = TMath::Max(rdmax,TMath::Abs(rdiff)); //      } //     //   For the last case, a=b, the algorithm advances each array by one index in an //   attempt to move through the equality. However, this is incorrect when one or //   the other of a or b (or both) have a repeated value, call it x. For the KS //   statistic to be computed properly, rdiff needs to be calculated after all of //   the a and b at x have been tallied (this is due to the definition of the //   empirical distribution function; another way to convince yourself that the //   old CERNLIB method is wrong is that it implies that the function defined as the //   difference between a and b is multi-valued at x -- besides being ugly, this //   would invalidate Kolmogorov's theorem). //     //   The solution is to just add while-loops into the equality-case handling to //   perform the tally: //     //         } else { //            double x = a[ia-1]; //            while(a[ia-1] == x && ia <= na) { //              rdiff -= sa; //              ia++; //            } //            while(b[ib-1] == x && ib <= nb) { //              rdiff += sb; //              ib++; //            } //            if (ia > na) {ok = kTRUE; break;} //            if (ib > nb) {ok = kTRUE; break;} //         }
Improve TMath::KolmogorovTest (Jason Detwiler)
//
//  Method Improvement by Jason A Detwiler (JADetwiler@lbl.gov)
//  -----------------------------------------------------------
//   The nuts-and-bolts of the TMath::KolmogorovTest() algorithm is a for-loop
//   over the two sorted arrays a and b representing empirical distribution
//   functions. The for-loop handles 3 cases: when the next points to be 
//   evaluated satisfy a>b, a<b, or a=b:
//    
//      for (Int_t i=0;i<na+nb;i++) {
//         if (a[ia-1] < b[ib-1]) {
//            rdiff -= sa;
//            ia++;
//            if (ia > na) {ok = kTRUE; break;}
//         } else if (a[ia-1] > b[ib-1]) {
//            rdiff += sb;
//            ib++;
//            if (ib > nb) {ok = kTRUE; break;}
//         } else {
//            rdiff += sb - sa;
//            ia++;
//            ib++;
//            if (ia > na) {ok = kTRUE; break;}
//            if (ib > nb) {ok = kTRUE; break;}
//        }
//         rdmax = TMath::Max(rdmax,TMath::Abs(rdiff));
//      }
//    
//   For the last case, a=b, the algorithm advances each array by one index in an
//   attempt to move through the equality. However, this is incorrect when one or
//   the other of a or b (or both) have a repeated value, call it x. For the KS
//   statistic to be computed properly, rdiff needs to be calculated after all of
//   the a and b at x have been tallied (this is due to the definition of the
//   empirical distribution function; another way to convince yourself that the
//   old CERNLIB method is wrong is that it implies that the function defined as the
//   difference between a and b is multi-valued at x -- besides being ugly, this
//   would invalidate Kolmogorov's theorem).
//    
//   The solution is to just add while-loops into the equality-case handling to
//   perform the tally:
//    
//         } else {
//            double x = a[ia-1];
//            while(a[ia-1] == x && ia <= na) {
//              rdiff -= sa;
//              ia++;
//            }
//            while(b[ib-1] == x && ib <= nb) {
//              rdiff += sb;
//              ib++;
//            }
//            if (ia > na) {ok = kTRUE; break;}
//            if (ib > nb) {ok = kTRUE; break;}
//         }


git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@21031 27541ba8-7e3a-0410-8455-c3a389f83636

krafczyk/root,pspe/root,bbockelm/root,zzxuanyuan/root,thomaskeck/root,beniz/root,omazapa/root-old,CristinaCristescu/root,CristinaCristescu/root,Y--/root,krafczyk/root,evgeny-boger/root,lgiommi/root,jrtomps/root,strykejern/TTreeReader,lgiommi/root,arch1tect0r/root,mhuwiler/rootauto,smarinac/root,dfunke/root,bbockelm/root,Y--/root,mhuwiler/rootauto,cxx-hep/root-cern,perovic/root,evgeny-boger/root,olifre/root,root-mirror/root,Y--/root,evgeny-boger/root,nilqed/root,kirbyherm/root-r-tools,root-mirror/root,arch1tect0r/root,arch1tect0r/root,kirbyherm/root-r-tools,krafczyk/root,mhuwiler/rootauto,krafczyk/root,satyarth934/root,buuck/root,BerserkerTroll/root,satyarth934/root,simonpf/root,sawenzel/root,lgiommi/root,buuck/root,evgeny-boger/root,beniz/root,agarciamontoro/root,vukasinmilosevic/root,nilqed/root,0x0all/ROOT,abhinavmoudgil95/root,georgtroska/root,georgtroska/root,sawenzel/root,karies/root,pspe/root,olifre/root,Duraznos/root,vukasinmilosevic/root,davidlt/root,alexschlueter/cern-root,0x0all/ROOT,zzxuanyuan/root,satyarth934/root,sirinath/root,karies/root,smarinac/root,omazapa/root-old,olifre/root,mkret2/root,CristinaCristescu/root,kirbyherm/root-r-tools,ffurano/root5,tc3t/qoot,Dr15Jones/root,davidlt/root,CristinaCristescu/root,tc3t/qoot,agarciamontoro/root,esakellari/root,pspe/root,thomaskeck/root,ffurano/root5,Dr15Jones/root,perovic/root,CristinaCristescu/root,omazapa/root-old,zzxuanyuan/root,smarinac/root,mhuwiler/rootauto,jrtomps/root,alexschlueter/cern-root,abhinavmoudgil95/root,jrtomps/root,0x0all/ROOT,alexschlueter/cern-root,esakellari/root,BerserkerTroll/root,mattkretz/root,kirbyherm/root-r-tools,abhinavmoudgil95/root,vukasinmilosevic/root,veprbl/root,smarinac/root,beniz/root,dfunke/root,gganis/root,cxx-hep/root-cern,Dr15Jones/root,lgiommi/root,abhinavmoudgil95/root,abhinavmoudgil95/root,zzxuanyuan/root-compressor-dummy,pspe/root,karies/root,tc3t/qoot,ffurano/root5,karies/root,Y--/root,sawenzel/root,0x0all/ROOT,Duraznos/root,omazapa/root-old,evgeny-boger/root,esakellari/root,0x0all/ROOT,omazapa/root-old,lgiommi/root,zzxuanyuan/root-compressor-dummy,davidlt/root,perovic/root,beniz/root,gbitzes/root,arch1tect0r/root,omazapa/root,sirinath/root,pspe/root,root-mirror/root,sbinet/cxx-root,lgiommi/root,sirinath/root,esakellari/root,vukasinmilosevic/root,tc3t/qoot,Duraznos/root,satyarth934/root,omazapa/root,zzxuanyuan/root,Duraznos/root,karies/root,evgeny-boger/root,georgtroska/root,zzxuanyuan/root-compressor-dummy,simonpf/root,sawenzel/root,nilqed/root,pspe/root,omazapa/root,olifre/root,davidlt/root,buuck/root,tc3t/qoot,dfunke/root,sbinet/cxx-root,ffurano/root5,bbockelm/root,CristinaCristescu/root,krafczyk/root,strykejern/TTreeReader,Dr15Jones/root,cxx-hep/root-cern,abhinavmoudgil95/root,abhinavmoudgil95/root,thomaskeck/root,sirinath/root,gbitzes/root,gganis/root,omazapa/root,perovic/root,sawenzel/root,esakellari/root,ffurano/root5,satyarth934/root,perovic/root,abhinavmoudgil95/root,cxx-hep/root-cern,sirinath/root,smarinac/root,abhinavmoudgil95/root,sbinet/cxx-root,root-mirror/root,Dr15Jones/root,zzxuanyuan/root-compressor-dummy,gganis/root,gbitzes/root,alexschlueter/cern-root,0x0all/ROOT,alexschlueter/cern-root,vukasinmilosevic/root,buuck/root,mkret2/root,BerserkerTroll/root,vukasinmilosevic/root,alexschlueter/cern-root,Y--/root,gganis/root,mattkretz/root,sbinet/cxx-root,Y--/root,root-mirror/root,davidlt/root,sirinath/root,sbinet/cxx-root,agarciamontoro/root,dfunke/root,zzxuanyuan/root,agarciamontoro/root,sbinet/cxx-root,zzxuanyuan/root-compressor-dummy,arch1tect0r/root,buuck/root,satyarth934/root,gganis/root,esakellari/root,sawenzel/root,esakellari/my_root_for_test,zzxuanyuan/root,perovic/root,lgiommi/root,bbockelm/root,zzxuanyuan/root,sbinet/cxx-root,mhuwiler/rootauto,evgeny-boger/root,evgeny-boger/root,Duraznos/root,vukasinmilosevic/root,strykejern/TTreeReader,Duraznos/root,esakellari/my_root_for_test,sirinath/root,pspe/root,krafczyk/root,Duraznos/root,gbitzes/root,sawenzel/root,mattkretz/root,mattkretz/root,beniz/root,gganis/root,olifre/root,agarciamontoro/root,cxx-hep/root-cern,veprbl/root,veprbl/root,bbockelm/root,dfunke/root,zzxuanyuan/root,thomaskeck/root,krafczyk/root,BerserkerTroll/root,gbitzes/root,nilqed/root,satyarth934/root,jrtomps/root,krafczyk/root,smarinac/root,beniz/root,esakellari/my_root_for_test,strykejern/TTreeReader,veprbl/root,BerserkerTroll/root,Y--/root,arch1tect0r/root,omazapa/root-old,perovic/root,georgtroska/root,smarinac/root,root-mirror/root,abhinavmoudgil95/root,dfunke/root,jrtomps/root,gbitzes/root,BerserkerTroll/root,thomaskeck/root,mkret2/root,lgiommi/root,arch1tect0r/root,karies/root,mhuwiler/rootauto,CristinaCristescu/root,Y--/root,sirinath/root,mhuwiler/rootauto,olifre/root,agarciamontoro/root,simonpf/root,Duraznos/root,gganis/root,jrtomps/root,strykejern/TTreeReader,Y--/root,simonpf/root,tc3t/qoot,BerserkerTroll/root,nilqed/root,davidlt/root,0x0all/ROOT,zzxuanyuan/root-compressor-dummy,davidlt/root,esakellari/my_root_for_test,Dr15Jones/root,gganis/root,jrtomps/root,omazapa/root-old,satyarth934/root,omazapa/root,thomaskeck/root,strykejern/TTreeReader,mattkretz/root,vukasinmilosevic/root,mkret2/root,omazapa/root,Dr15Jones/root,karies/root,zzxuanyuan/root-compressor-dummy,buuck/root,tc3t/qoot,root-mirror/root,satyarth934/root,esakellari/root,gbitzes/root,mkret2/root,omazapa/root,thomaskeck/root,dfunke/root,zzxuanyuan/root-compressor-dummy,kirbyherm/root-r-tools,mkret2/root,thomaskeck/root,buuck/root,CristinaCristescu/root,buuck/root,georgtroska/root,ffurano/root5,zzxuanyuan/root,davidlt/root,lgiommi/root,CristinaCristescu/root,mattkretz/root,mattkretz/root,omazapa/root-old,omazapa/root-old,esakellari/my_root_for_test,mattkretz/root,omazapa/root-old,tc3t/qoot,sawenzel/root,mkret2/root,BerserkerTroll/root,esakellari/my_root_for_test,nilqed/root,zzxuanyuan/root,pspe/root,veprbl/root,veprbl/root,Duraznos/root,mhuwiler/rootauto,simonpf/root,perovic/root,pspe/root,lgiommi/root,arch1tect0r/root,omazapa/root,Duraznos/root,davidlt/root,agarciamontoro/root,ffurano/root5,root-mirror/root,smarinac/root,georgtroska/root,agarciamontoro/root,sawenzel/root,esakellari/root,cxx-hep/root-cern,nilqed/root,georgtroska/root,evgeny-boger/root,zzxuanyuan/root-compressor-dummy,veprbl/root,veprbl/root,kirbyherm/root-r-tools,dfunke/root,esakellari/my_root_for_test,gbitzes/root,cxx-hep/root-cern,zzxuanyuan/root,bbockelm/root,georgtroska/root,root-mirror/root,olifre/root,alexschlueter/cern-root,karies/root,vukasinmilosevic/root,nilqed/root,nilqed/root,georgtroska/root,veprbl/root,Y--/root,root-mirror/root,root-mirror/root,karies/root,tc3t/qoot,jrtomps/root,tc3t/qoot,abhinavmoudgil95/root,veprbl/root,krafczyk/root,Duraznos/root,olifre/root,sawenzel/root,pspe/root,agarciamontoro/root,cxx-hep/root-cern,mattkretz/root,gganis/root,olifre/root,arch1tect0r/root,buuck/root,perovic/root,buuck/root,esakellari/root,thomaskeck/root,arch1tect0r/root,zzxuanyuan/root-compressor-dummy,georgtroska/root,gganis/root,gbitzes/root,lgiommi/root,smarinac/root,davidlt/root,beniz/root,gbitzes/root,jrtomps/root,buuck/root,omazapa/root,mkret2/root,gganis/root,krafczyk/root,bbockelm/root,zzxuanyuan/root,sbinet/cxx-root,beniz/root,evgeny-boger/root,mhuwiler/rootauto,pspe/root,esakellari/my_root_for_test,agarciamontoro/root,Y--/root,bbockelm/root,jrtomps/root,BerserkerTroll/root,evgeny-boger/root,beniz/root,karies/root,arch1tect0r/root,mattkretz/root,satyarth934/root,strykejern/TTreeReader,simonpf/root,beniz/root,sbinet/cxx-root,CristinaCristescu/root,mhuwiler/rootauto,beniz/root,0x0all/ROOT,sawenzel/root,jrtomps/root,mhuwiler/rootauto,nilqed/root,olifre/root,simonpf/root,mkret2/root,zzxuanyuan/root-compressor-dummy,esakellari/root,karies/root,BerserkerTroll/root,dfunke/root,omazapa/root-old,georgtroska/root,sirinath/root,mkret2/root,smarinac/root,bbockelm/root,0x0all/ROOT,sbinet/cxx-root,gbitzes/root,sbinet/cxx-root,sirinath/root,vukasinmilosevic/root,sirinath/root,omazapa/root,bbockelm/root,BerserkerTroll/root,simonpf/root,esakellari/root,agarciamontoro/root,mkret2/root,bbockelm/root,simonpf/root,thomaskeck/root,perovic/root,esakellari/my_root_for_test,davidlt/root,omazapa/root,dfunke/root,mattkretz/root,olifre/root,CristinaCristescu/root,simonpf/root,kirbyherm/root-r-tools,esakellari/my_root_for_test,simonpf/root,satyarth934/root,veprbl/root,vukasinmilosevic/root,nilqed/root,perovic/root,krafczyk/root,dfunke/root