Ignore:
Timestamp:
08/08/06 17:51:35 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MMath.cc

    r7672 r7867  
    161161}
    162162
     163// ------------------------------------------------------------------------
     164//
     165// Return the median value of the distribution of abs(a[i]-Median)
     166//
     167template <class Size, class Element>
     168Double_t MMath::MedianDevImp(Size n, const Element *a)
     169{
     170    // Get median of distribution
     171    const Double_t med = TMath::Median(n, a);
     172
     173    // Allocate space for distribution
     174    Double_t *arr = new Double_t[n];
     175
     176    // Create the abs(a[i]-med) distribution
     177    for (int i=0; i<n; i++)
     178        arr[i] = TMath::Abs(a[i]-med);
     179
     180    // FIXME: GausProb() is a workaround. It should be taken into account in Median!
     181    const Double_t rc = TMath::Median(n, arr);
     182
     183    // delete space
     184    delete arr;
     185
     186    // return result
     187    return rc;
     188}
     189
     190// ------------------------------------------------------------------------
     191//
     192// Return the median value of the distribution of abs(a[i]-Median)
     193//
     194Double_t MMath::MedianDev(Long64_t n, const Short_t *a)
     195{
     196    return MedianDevImp(n, a);
     197}
     198
     199// ------------------------------------------------------------------------
     200//
     201// Return the median value of the distribution of abs(a[i]-Median)
     202//
     203Double_t MMath::MedianDev(Long64_t n, const Int_t *a)
     204{
     205    return MedianDevImp(n, a);
     206}
     207
     208// ------------------------------------------------------------------------
     209//
     210// Return the median value of the distribution of abs(a[i]-Median)
     211//
     212Double_t MMath::MedianDev(Long64_t n, const Float_t *a)
     213{
     214    return MedianDevImp(n, a);
     215}
     216
     217// ------------------------------------------------------------------------
     218//
     219// Return the median value of the distribution of abs(a[i]-Median)
     220//
     221Double_t MMath::MedianDev(Long64_t n, const Double_t *a)
     222{
     223    return MedianDevImp(n, a);
     224}
     225
     226// ------------------------------------------------------------------------
     227//
     228// Return the median value of the distribution of abs(a[i]-Median)
     229//
     230Double_t MMath::MedianDev(Long64_t n, const Long_t *a)
     231{
     232    return MedianDevImp(n, a);
     233}
     234
     235// ------------------------------------------------------------------------
     236//
     237// Return the median value of the distribution of abs(a[i]-Median)
     238//
     239Double_t MMath::MedianDev(Long64_t n, const Long64_t *a)
     240{
     241    return MedianDevImp(n, a);
     242}
     243
    163244// --------------------------------------------------------------------------
    164245//
  • trunk/MagicSoft/Mars/mbase/MMath.h

    r7719 r7867  
    1818
    1919    Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
     20
     21    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a);
     22    Double_t  MedianDev(Long64_t n, const Short_t  *a);
     23    Double_t  MedianDev(Long64_t n, const Int_t    *a);
     24    Double_t  MedianDev(Long64_t n, const Float_t  *a);
     25    Double_t  MedianDev(Long64_t n, const Double_t *a);
     26    Double_t  MedianDev(Long64_t n, const Long_t   *a);
     27    Double_t  MedianDev(Long64_t n, const Long64_t *a);
    2028
    2129    Double_t Significance(Double_t s, Double_t b);
Note: See TracChangeset for help on using the changeset viewer.