public static double uncenteredCorrelation(NumberVector x,NumberVector y){
  final int xdim=x.getDimensionality(), ydim=y.getDimensionality();
  if (xdim != ydim) {
    throw new IllegalArgumentException("Invalid arguments: number vectors differ in dimensionality.");
  }
  double sumXX=0., sumYY=0., sumXY=0.;
  for (int i=0; i < xdim; i++) {
    final double xv=x.doubleValue(i), yv=y.doubleValue(i);
    sumXX+=xv * xv;
    sumYY+=yv * yv;
    sumXY+=xv * yv;
  }
  if (!(sumXX > 0. && sumYY > 0.)) {
    return (sumXX == sumYY) ? 1. : 0.;
  }
  return sumXY / Math.sqrt(sumXX * sumYY);
}

public static double uncenteredCorrelation ( NumberVector x , NumberVector y ) { final int xdim = x . getDimensionality ( ) , ydim = y . getDimensionality ( ) ; if ( xdim != ydim ) { throw new IllegalArgumentException ( "Invalid arguments: number vectors differ in dimensionality." ) ; } double sumXX = 0. , sumYY = 0. , sumXY = 0. ; for ( int i = 0 ; i < xdim ; i ++ ) { final double xv = x . doubleValue ( i ) , yv = y . doubleValue ( i ) ; sumXX += xv * xv ; sumYY += yv * yv ; sumXY += xv * yv ; } if ( ! ( sumXX > 0. && sumYY > 0. ) ) { return ( sumXX == sumYY ) ? 1. : 0. ; } return sumXY / Math . sqrt ( sumXX * sumYY ) ; }
compute the uncentered correlation of two vectors .
