public double getMean() {
        if (total_size == 0) return Double.NaN;

        double mean = 0.0;
        if (type == Integer.class) {
            for (int i = 0; i < total_size; i++) {
                mean += ((int[])vals)[i];
            }
            mean = mean / (double)total_size;
        } else {
            for (int i = 0; i < total_size; i++) {
                mean += ((double[])vals)[i];
            }
            mean = mean / (double)total_size;
        }
        return mean;
    }