Mahout
  1. Mahout
  2. MAHOUT-209

Add aggregate() methods for Vector

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.3
    • Component/s: Math
    • Labels:
      None
    • Environment:

      all

      Description

      As discussed in MAHOUT-165 at some point, Vector (and Matrix, but let's put that on a separate ticket) could do with a nice exposure of methods like the following:

      // this can get optimized, of course
      
        public double aggregate(Vector other, BinaryFunction aggregator, BinaryFunction combiner) {
          double result = 0;
          for(int i=0; i<size(); i++) {
            result = aggregator.apply(result, combiner.apply(getQuick(i), other.getQuick(i)));
          }
          return result;
        }
      

      this is good for generalized inner products and distances. Also nice:

        public double aggregate(BinaryFunction aggregator, UnaryFunction map) {
          double result = 0;
          for(int i=0; i<size(); i++) {
            result = aggregator.apply(result, map.apply(getQuick(i)) );
          }
          return result;
        }
      

      Which generalizes norms and statistics (mean, median, stdDev) and things like that (number of positive values, or negative values, etc...).

      These kind of thing exists in Colt, and we could just surface it up to the top.

        Activity

          People

          • Assignee:
            Jake Mannix
            Reporter:
            Jake Mannix
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development