public static int SAX(int levels,double value){
  if (levels > SAX_MAX_LEVELS || levels < 1) {
    throw new RuntimeException();
  }
  if (null == INVNORM_BOUNDS[levels - 1]) {
synchronized (INVNORM_BOUNDS) {
      if (null == INVNORM_BOUNDS[levels - 1]) {
        INVNORM_BOUNDS[levels - 1]=getBounds(1 << levels);
      }
    }
  }
  int idx=Arrays.binarySearch(INVNORM_BOUNDS[levels - 1],value);
  if (idx >= 0) {
    return idx;
  }
 else {
    return -idx - 1;
  }
}

public static int SAX ( int levels , double value ) { if ( levels > SAX_MAX_LEVELS || levels < 1 ) { throw new RuntimeException ( ) ; } if ( null == INVNORM_BOUNDS [ levels - 1 ] ) { synchronized ( INVNORM_BOUNDS ) { if ( null == INVNORM_BOUNDS [ levels - 1 ] ) { INVNORM_BOUNDS [ levels - 1 ] = getBounds ( 1 << levels ) ; } } } int idx = Arrays . binarySearch ( INVNORM_BOUNDS [ levels - 1 ] , value ) ; if ( idx >= 0 ) { return idx ; } else { return - idx - 1 ; } }
return a sax symbol given a double value and a number of levels . the returned symbol will use an alphabet of 2 * * level elements .
