code: public double saxMinDist(char[] a, char[] b, double[][] distanceMatrix, int n, int w)
        throws SAXException {
      if (a.length == b.length) {
        double dist = 0.0D;
        for (int i = 0; i < a.length; i++) {
          if (Character.isLetter(a[i]) && Character.isLetter(b[i])) {
            // ... forms have numeric values from 10 through 35
            int numA = Character.getNumericValue(a[i]) - 10;
            int numB = Character.getNumericValue(b[i]) - 10;
            int maxIdx = distanceMatrix[0].length;
            if (numA > (maxIdx - 1) || numA < 0 || numB > (maxIdx - 1) || numB < 0) {
              throw new SAXException(
                  "The character index greater than " + maxIdx + " or less than 0!");
            }
            double localDist = distanceMatrix[numA][numB];
            dist = dist + localDist * localDist;
          }
          else {
            throw new SAXException("Non-literal character found!");
          }
        }
        return Math.sqrt((double) n / (double) w) * Math.sqrt(dist);
      }
      else {
        throw new SAXException("Data arrays lengths are not equal!");
      }
    }
docs: This function implements SAX MINDIST function which uses alphabet based distance matrix.
  
  @param a The SAX string.
  @param b The SAX string.
  @param distanceMatrix The distance matrix to use.
  @param n the time series length (sliding window length).
  @param w the number of PAA segments.
  @return distance between strings.
  @throws SAXException If error occurs.