Changeset 1582 for trunk


Ignore:
Timestamp:
11/06/02 16:40:41 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r1579 r1582  
    4545#include "MHMatrix.h"
    4646
    47 #include <math.h>   // abs for Alphas
    48 #include <stdlib.h> // abs for some Linux machines
    49 
    5047#include <fstream.h>
    5148
     
    384381// represented by the covariance metrix m.
    385382//  - If n<0 the kernel method is applied and
    386 //    sum(epx(-d)/n is returned.
    387 //  - For n>=0 the n nearest neighbors are summed and
    388 //    sqrt(sum(d))/n is returned.
     383//    -log(sum(epx(-d/h))/n) is returned.
     384//  - For n>0 the n nearest neighbors are summed and
     385//    sqrt(sum(d)/n) is returned.
    389386//  - if n==0 all distances are summed
    390387//
     
    395392        TVector d = evt;
    396393        d *= m;
    397         return sqrt(d*evt);
     394        return TMath::Sqrt(d*evt);
    398395    }
    399396
     
    430427    TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE);
    431428
    432     const Int_t n = abs(num)<rows ? abs(num) : rows;
     429    const Int_t n = TMath::Abs(num)<rows ? TMath::Abs(num) : rows;
    433430
    434431    if (num<0)
    435432    {
    436433        //
    437         // Kernel function sum
     434        // Kernel function sum (window size h set according to literature)
    438435        //
    439         const Double_t h = 1;
     436        const Double_t h    = TMath::Power(rows, -1./(cols+4));
     437        const Double_t hwin = h*h*2;
    440438
    441439        Double_t res = 0;
    442440        for (int i=0; i<n; i++)
    443             res += exp(-dists[idx[i]]/h);
    444 
    445         return -log(res/n);
     441            res += TMath::Exp(-dists[idx[i]]/hwin);
     442
     443        return -TMath::Log(res/n);
    446444    }
    447445    else
     
    454452            res += dists[idx[i]];
    455453
    456         return sqrt(res/n);
     454        return TMath::Sqrt(res/n);
    457455    }
    458456}
Note: See TracChangeset for help on using the changeset viewer.