private void computeAxisVariance(List<P> points) {
		int numPoints = points.size();

		for( int i = 0; i < N; i++ ) {
			mean[i] = 0;
			var[i] = 0;
		}

		// compute the mean
		for( int i = 0; i < numPoints; i++ ) {
			P p = points.get(i);

			for( int j = 0; j < N; j++ ) {
				mean[j] += distance.valueAt(p,j);
			}
		}

		for( int i = 0; i < N; i++ ) {
			mean[i] /= numPoints;
		}

		// compute the variance * N
		for( int i = 0; i < numPoints; i++ ) {
			P p = points.get(i);

			for( int j = 0; j < N; j++ ) {
				double d = mean[j] - distance.valueAt(p,j);
				var[j] += d*d;
			}
		}
	}
private void computeAxisVariance ( List < P > points ) { int numPoints = points . size ( ) ; for ( int i = 0 ; i < N ; i ++ ) { mean [ i ] = 0 ; var [ i ] = 0 ; } for ( int i = 0 ; i < numPoints ; i ++ ) { P p = points . get ( i ) ; for ( int j = 0 ; j < N ; j ++ ) { mean [ j ] += distance . valueAt ( p , j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { mean [ i ] /= numPoints ; } for ( int i = 0 ; i < numPoints ; i ++ ) { P p = points . get ( i ) ; for ( int j = 0 ; j < N ; j ++ ) { double d = mean [ j ] - distance . valueAt ( p , j ) ; var [ j ] += d * d ; } } }
Select the maximum variance as the split