Ignore:
Timestamp:
11/08/02 10:04:04 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHMatrix.cc

    r1582 r1593  
    427427    TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE);
    428428
    429     const Int_t n = TMath::Abs(num)<rows ? TMath::Abs(num) : rows;
     429    Int_t from = 0;
     430    Int_t to   = TMath::Abs(num)<rows ? TMath::Abs(num) : rows;
     431    //
     432    // This is a zero-suppression for the case a test- and trainings
     433    // sample is identical. This would result in an unwanted leading
     434    // zero in the array. To suppress also numerical uncertanties of
     435    // zero we cut at 1e-5. Due to Rudy this should be enough. If
     436    // you encounter problems we can also use (eg) 1e-25
     437    //
     438    if (dists[idx[0]]<1e-5)
     439    {
     440        from++;
     441        to ++;
     442        if (to>rows)
     443            to = rows;
     444    }
    430445
    431446    if (num<0)
     
    438453
    439454        Double_t res = 0;
    440         for (int i=0; i<n; i++)
     455        for (int i=from; i<to; i++)
    441456            res += TMath::Exp(-dists[idx[i]]/hwin);
    442457
    443         return -TMath::Log(res/n);
     458        return -TMath::Log(res/(to-from));
    444459    }
    445460    else
     
    449464        //
    450465        Double_t res = 0;
    451         for (int i=0; i<n; i++)
     466        for (int i=from; i<to; i++)
    452467            res += dists[idx[i]];
    453468
    454         return TMath::Sqrt(res/n);
     469        return TMath::Sqrt(res/(to-from));
    455470    }
    456471}
Note: See TracChangeset for help on using the changeset viewer.