code: public static double variance(double[] x, double mean) {
          if (x.length == 0) {
              return Double.NaN;
          }
          if (x.length == 1) {
              return 0.0;
          }
          double result = 0.0;
          for (double i : x) {
              result += (i - mean) * (i - mean);
          }
          result /= -1 + x.length;
          return result;
      }
docs: Computes the variance of the vector using the given mean
  
  @param x is the vector
  @param mean is the mean value of the vector
  @return ` \sum_i{ (x_i - \bar{x})^2 } / (|x| - 1) `