common.cpp 743 B

12345678910111213141516171819
  1. #include "common.h"
  2. namespace NKiwiAggr {
  3. TWeightedValue CalcDistanceQuality(const TWeightedValue& left, const TWeightedValue& right) {
  4. return TWeightedValue(right.first - left.first, left.first);
  5. }
  6. TWeightedValue CalcWeightQuality(const TWeightedValue& left, const TWeightedValue& right) {
  7. return TWeightedValue(right.second + left.second, left.first);
  8. }
  9. TWeightedValue CalcWardQuality(const TWeightedValue& left, const TWeightedValue& right) {
  10. const double N1 = left.second;
  11. const double N2 = right.second;
  12. const double mu1 = left.first;
  13. const double mu2 = right.first;
  14. return TWeightedValue(N1 * N2 / (N1 + N2) * (mu1 - mu2) * (mu1 - mu2), left.first);
  15. }
  16. }