Changeset 7868 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 08/09/06 10:39:45 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MMath.cc
r7867 r7868 168 168 Double_t MMath::MedianDevImp(Size n, const Element *a) 169 169 { 170 // Sanity check 171 if (n <= 0 || !a) 172 return 0; 173 170 174 // Get median of distribution 171 175 const Double_t med = TMath::Median(n, a); 172 176 173 // Allocate space for distribution174 Double_t *arr = new Double_t[n];175 176 177 // Create the abs(a[i]-med) distribution 178 Double_t arr[n]; 177 179 for (int i=0; i<n; i++) 178 180 arr[i] = TMath::Abs(a[i]-med); 179 181 180 182 // 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; 183 return TMath::Median(n, arr); 184 /* 185 // Sort distribution 186 Long64_t idx[n]; 187 TMath::SortImp(n, arr, idx, kTRUE); 188 189 // Define where to divide 190 const Int_t div = TMath::Nint(n*MMath::GaussProb(1.0)); 191 192 // Calculate result 193 Double_t dev = TMath::KOrdStat(n, arr, div, idx); 194 if (n%2 == 0) 195 { 196 dev += TMath::KOrdStat(n, arr, div-1, idx); 197 dev /= 2; 198 } 199 200 return dev; 201 */ 188 202 } 189 203
Note:
See TracChangeset
for help on using the changeset viewer.