public double calculateSimilarity(PatternReference pattern){
  final int[] otherTF=pattern.getTermFrequency();
  double score=0;
  for (int i=0; i < termFrequency.length; i++) {
    score+=termFrequency[i] * otherTF[i];
  }
  return score / (pattern.getTFMagnitude() * getTFMagnitude());
}

public double calculateSimilarity ( PatternReference pattern ) { final int [ ] otherTF = pattern . getTermFrequency ( ) ; double score = 0 ; for ( int i = 0 ; i < termFrequency . length ; i ++ ) { score += termFrequency [ i ] * otherTF [ i ] ; } return score / ( pattern . getTFMagnitude ( ) * getTFMagnitude ( ) ) ; }
calculate similarity between this and another pattern , uses the cosine distance .
