public double approximationDistanceAlphabet(double[] ts,int winSize,int paaSize,int alphabetSize,double normThreshold) throws Exception {
  double resDistance=0d;
  int windowCounter=0;
  double[] centralLines=na.getCentralCuts(alphabetSize);
  for (int i=0; i < ts.length - winSize + 1; i++) {
    double[] subseries=Arrays.copyOfRange(ts,i,i + winSize);
    double subsequenceDistance=0.;
    if (tsProcessor.stDev(subseries) > normThreshold) {
      subseries=tsProcessor.znorm(subseries,normThreshold);
    }
    double[] paa=tsProcessor.paa(subseries,paaSize);
    int[] leterIndexes=tsProcessor.ts2Index(paa,na,alphabetSize);
    windowCounter++;
    for (int j=0; j < paa.length; j++) {
      int letterIdx=leterIndexes[j];
      double cLine=centralLines[letterIdx];
      subsequenceDistance=subsequenceDistance + ed.distance(cLine,paa[j]);
    }
    resDistance=resDistance + subsequenceDistance / paa.length;
  }
  return resDistance / (double)windowCounter;
}

public double approximationDistanceAlphabet ( double [ ] ts , int winSize , int paaSize , int alphabetSize , double normThreshold ) throws Exception { double resDistance = 0d ; int windowCounter = 0 ; double [ ] centralLines = na . getCentralCuts ( alphabetSize ) ; for ( int i = 0 ; i < ts . length - winSize + 1 ; i ++ ) { double [ ] subseries = Arrays . copyOfRange ( ts , i , i + winSize ) ; double subsequenceDistance = 0. ; if ( tsProcessor . stDev ( subseries ) > normThreshold ) { subseries = tsProcessor . znorm ( subseries , normThreshold ) ; } double [ ] paa = tsProcessor . paa ( subseries , paaSize ) ; int [ ] leterIndexes = tsProcessor . ts2Index ( paa , na , alphabetSize ) ; windowCounter ++ ; for ( int j = 0 ; j < paa . length ; j ++ ) { int letterIdx = leterIndexes [ j ] ; double cLine = centralLines [ letterIdx ] ; subsequenceDistance = subsequenceDistance + ed . distance ( cLine , paa [ j ] ) ; } resDistance = resDistance + subsequenceDistance / paa . length ; } return resDistance / ( double ) windowCounter ; }
computes the distance between approximated values and the real ts .
