public static double var(int[] array) {
        if (array.length < 2) {
            throw new IllegalArgumentException("Array length is less than 2.");
        }

        double sum = 0.0;
        double sumsq = 0.0;
        for (int xi : array) {
            sum += xi;
            sumsq += xi * xi;
        }

        int n = array.length - 1;
        return sumsq / n - (sum / array.length) * (sum / n);
    }
@Test
    public void testVar_doubleArr() {
        System.out.println("var");
        double[] data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
        assertEquals(7.5, MathEx.var(data), 1E-6);
    }