code: public double[][] getMaxedMarginals() {
      double[][] maxValues = new double[neighborIndices.length][];
      for (int i = 0; i < neighborIndices.length; i++) {
        maxValues[i] = new double[getDimensions()[i]];
        for (int j = 0; j < maxValues[i].length; j++) maxValues[i][j] = Double.NEGATIVE_INFINITY;
      }
  
      // Get max values
  
      // OPTIMIZATION:
      // Rather than use the standard iterator, which creates lots of int[] arrays on the heap, which need to be GC'd,
      // we use the fast version that just mutates one array. Since this is read once for us here, this is ideal.
  
      Iterator<int[]> fastPassByReferenceIterator = fastPassByReferenceIterator();
      int[] assignment = fastPassByReferenceIterator.next();
      while (true) {
        double v = getAssignmentLogValue(assignment);
        for (int i = 0; i < neighborIndices.length; i++) {
          if (maxValues[i][assignment[i]] < v) maxValues[i][assignment[i]] = v;
        }
        // This mutates the resultAssignment[] array, rather than creating a new one
        if (fastPassByReferenceIterator.hasNext()) {
          fastPassByReferenceIterator.next();
        } else break;
      }
  
      for (int i = 0; i < neighborIndices.length; i++) {
        normalizeLogArr(maxValues[i]);
      }
  
      return maxValues;
    }
docs: Convenience function to max out all but one variable, and return the marginal array.
  
  @return an array of doubles one-to-one with variable states for each variable