Compute the uncentered correlation of two vectors.

@param x first NumberVector
@param y second NumberVector
@return the uncentered correlation coefficient for x and y
5393
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;
    }
    // One or both series were constant:
    if(!(sumXX > 0. && sumYY > 0.)) {
      return (sumXX == sumYY) ? 1. : 0.;
    }
    return sumXY / FastMath.sqrt(sumXX * sumYY);
  }
1325405
public double intersectY(double y)
	{
		if (direction.y == 0)
			return Double.NaN;
		return (y - origin.y) / direction.y;
	}
1250367
@Override
	public void compute(double x, double y, Point2D_F64 out) {
		// initial estimate of undistorted point
		out.x = a11*x + a12*y + a13;
		out.y = a22*y + a23;

		removeRadial(out.x, out.y, params.radial, params.t1, params.t2, out, tol );
	}
639884
public double distanceFromCenter(final float x, final float y) {
        return Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2));
    }
1334001
@Pure
	public static Point2d L1_L3(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_1_N,
				LAMBERT_1_C,
				LAMBERT_1_XS,
				LAMBERT_1_YS);
		return NTFLambdaPhi_NTFLambert(
				ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
				LAMBERT_3_N,
				LAMBERT_3_C,
				LAMBERT_3_XS,
				LAMBERT_3_YS);
	}
1019913
@ExportConstructor
	public static org.geomajas.geometry.Coordinate constructor(double x, double y) {
		return new org.geomajas.geometry.Coordinate(x, y);
	}
917594
public static double pearson(int[] x, int[] y) {
        if (x.length != y.length)
            throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length));

        return 1 - Math.cor(x, y);
    }
6828
public static double cor(int[] x, int[] y) {
        if (x.length != y.length) {
            throw new IllegalArgumentException("Arrays have different length.");
        }

        if (x.length < 3) {
            throw new IllegalArgumentException("array length has to be at least 3.");
        }

        double Sxy = cov(x, y);
        double Sxx = var(x);
        double Syy = var(y);

        if (Sxx == 0 || Syy == 0) {
            return Double.NaN;
        }

        return Sxy / java.lang.Math.sqrt(Sxx * Syy);
    }
967429
public static double computeCorrelation(final double[] list1, final double[] list2)
    {
        // R = { N* (Sum(x*y) - Sum(x)*Sum(y)} / sqrt( { N* Sum( x**2 ) - Sum( x )**2} ) * sqrt ( {N
        // * Sum( y**2 ) - Sum( y )**2} )
        double sumXY = 0;
        double sumX = 0;
        double sumY = 0;
        double sumXsquares = 0;
        double sumYsquares = 0;
        final long N = list1.length; // we assume that both list are of equal length

        if (list1.length != list2.length) {
            log.fatal("Lists are not the same size (" + list1.length + " - " + list2.length + ").");
            System.exit(1);
        }

        for (int i = 0; i < N; i++) {
            final double x = list1[i];
            final double y = list2[i];
            sumXY += x * y;
            sumX += x;
            sumY += y;
            sumXsquares += x * x;
            sumYsquares += y * y;
        }

        final double nominator = (N * sumXY - sumX * sumY);

        final double root1 = N * sumXsquares - sumX * sumX;
        final double root2 = N * sumYsquares - sumY * sumY;
        final double denominator = Math.sqrt(root1) * Math.sqrt(root2);

        final double correlation = nominator / denominator;

        return correlation;
    }
870485
public static double Correlation(double[] p, double[] q) {

        double x = 0;
        double y = 0;

        for (int i = 0; i < p.length; i++) {
            x += -p[i];
            y += -q[i];
        }

        x /= p.length;
        y /= q.length;

        double num = 0;
        double den1 = 0;
        double den2 = 0;
        for (int i = 0; i < p.length; i++) {
            num += (p[i] + x) * (q[i] + y);

            den1 += Math.abs(Math.pow(p[i] + x, 2));
            den2 += Math.abs(Math.pow(q[i] + x, 2));
        }

        return 1 - (num / (Math.sqrt(den1) * Math.sqrt(den2)));

    }
130915
static public double ScafferF6(double x, double y) {
    double temp1 = x * x + y * y;
    double temp2 = Math.sin(Math.sqrt(temp1));
    double temp3 = 1.0 + 0.001 * temp1;
    return (0.5 + ((temp2 * temp2 - 0.5) / (temp3 * temp3)));
  }
131906
def center_of_mass(X, Y):
    
    X = np.asarray(X)
    Y = np.asarray(Y)
    return (X * Y).sum() / Y.sum()
1132837
public long dot(IntLongVector y) {
        if (y instanceof IntLongSortedVector) {
            IntLongSortedVector other = ((IntLongSortedVector) y);
            long dot = 0;
            int oc = 0;
            for (int c = 0; c < used; c++) {
                while (oc < other.used) {
                    if (other.indices[oc] < indices[c]) {
                        oc++;
                    } else if (indices[c] == other.indices[oc]) {
                        dot += values[c] * other.values[oc];
                        break;
                    } else {
                        break;
                    }
                }
            }
            return dot;
        } else {
            long dot = 0;
            for (int c = 0; c < used; c++) {
                dot += this.values[c] * y.get(indices[c]);
            }
            return dot;
        }
    }
156444
public double matthewsCorrelation(int classIdx) {
        return EvaluationUtils.matthewsCorrelation((long) truePositives.getCount(classIdx),
                        (long) falsePositives.getCount(classIdx), (long) falseNegatives.getCount(classIdx),
                        (long) trueNegatives.getCount(classIdx));
    }
354365
public static ImmutableVector2 createVector(final double x, final double y) {
		return new ImmutableVector2(new ImmutableData(2, 1) {
			@Override
			public double getQuick(int row, int col) {
				if (row == 0)
					return x;
				else
					return y;
			}
		});
	}
750339
@Pure
	public static Point2d L2_L1(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_2_N,
				LAMBERT_2_C,
				LAMBERT_2_XS,
				LAMBERT_2_YS);
		return NTFLambdaPhi_NTFLambert(
				ntfLambdaPhi.getX(), ntfLambdaPhi.getY(),
				LAMBERT_1_N,
				LAMBERT_1_C,
				LAMBERT_1_XS,
				LAMBERT_1_YS);
	}
1125383
public static double pearsonCorrelation(double[] x, double[] y) {
		double result;
		double sum_sq_x = 0, sum_sq_y = 0;
    double mean_x = x[0], mean_y = y[0];
		double sum_coproduct = 0;
		for(int i=2; i<x.length+1;++i) {
			double w = (i - 1)*1.0/i;
			double delta_x = x[i-1] - mean_x;
			double delta_y = y[i-1] - mean_y;
			sum_sq_x += delta_x * delta_x*w;
			sum_sq_y += delta_y * delta_y*w;
			sum_coproduct += delta_x * delta_y*w;
			mean_x += delta_x / i;
			mean_y += delta_y / i;
		}
		double pop_sd_x = Math.sqrt(sum_sq_x/x.length);
		double pop_sd_y = Math.sqrt(sum_sq_y/y.length);
		double cov_x_y = sum_coproduct / x.length;
    double denom = pop_sd_x*pop_sd_y;
    if(denom == 0.0)
      return 0.0;
    result = cov_x_y/denom;
		return result;
	}