docs: public static double coefficient(double[] x, double[] y) {
      final int xdim = x.length;
      final int ydim = y.length;
      if(xdim != ydim) {
        throw new IllegalArgumentException("Invalid arguments: arrays differ in length.");
      }
      if(xdim == 0) {
        throw new IllegalArgumentException("Empty vector.");
      }
      // Inlined computation of Pearson correlation, to avoid allocating objects!
      // This is a numerically stabilized version, avoiding sum-of-squares.
      double sumXX = 0., sumYY = 0., sumXY = 0.;
      double sumX = x[0], sumY = y[0];
      int i = 1;
      while(i < xdim) {
        final double xv = x[i], yv = y[i];
        // Delta to previous mean
        final double deltaX = xv * i - sumX;
        final double deltaY = yv * i - sumY;
        // Increment count first
        final double oldi = i; // Convert to double!
        ++i;
        final double f = 1. / (i * oldi);
        // Update
        sumXX += f * deltaX * deltaX;
        sumYY += f * deltaY * deltaY;
        // should equal deltaY * neltaX!
        sumXY += f * deltaX * deltaY;
        // Update sums
        sumX += xv;
        sumY += yv;
      }
      // One or both series were constant:
      if(!(sumXX > 0. && sumYY > 0.)) {
        return (sumXX == sumYY) ? 1. : 0.;
      }
      return sumXY / FastMath.sqrt(sumXX * sumYY);
    }