private double getNodeCost ( Node node , double [ ] center ) { int d = center . length ; double scatter = 0.0 ; for ( int i = 0 ; i < d ; i ++ ) { double x = ( node . sum [ i ] / node . count ) - center [ i ] ; scatter += x * x ; } return node . cost + node . count * scatter ; }
Returns the total contribution of all data in the given kd - tree node assuming they are all assigned to a mean at the given location .