Changeset 1593 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 11/08/02 10:04:04 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHMatrix.cc
r1582 r1593 427 427 TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE); 428 428 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 } 430 445 431 446 if (num<0) … … 438 453 439 454 Double_t res = 0; 440 for (int i= 0; i<n; i++)455 for (int i=from; i<to; i++) 441 456 res += TMath::Exp(-dists[idx[i]]/hwin); 442 457 443 return -TMath::Log(res/ n);458 return -TMath::Log(res/(to-from)); 444 459 } 445 460 else … … 449 464 // 450 465 Double_t res = 0; 451 for (int i= 0; i<n; i++)466 for (int i=from; i<to; i++) 452 467 res += dists[idx[i]]; 453 468 454 return TMath::Sqrt(res/ n);469 return TMath::Sqrt(res/(to-from)); 455 470 } 456 471 }
Note:
See TracChangeset
for help on using the changeset viewer.