public static double calcVariance(Instances data) {
		int n = data.numInstances();
		double[] mean = new double[data.numAttributes()];
		double var  = 0.0;
		for (int i = 0; i<data.numInstances(); i++) {
			Instance inst = data.instance(i);
			double[] x = inst.toDoubleArray();
			for (int j = 0 ; j < data.numAttributes(); j++) {
				mean[j] += x[j]/n;
			}
		}
		for (int i = 0; i<data.numInstances(); i++) {
			Instance inst = data.instance(i);
			double[] x = inst.toDoubleArray();
			for (int j = 0 ; j < data.numAttributes(); j++) {
				var += (x[j]-mean[j])*(x[j]-mean[j])/n;
			}
		}
		
		return var;
	}