public static int bins ( double [ ] x , double h ) { if ( h <= 0.0 ) { throw new IllegalArgumentException ( "Invalid bin width: " + h ) ; } double max = Math . max ( x ) ; double min = Math . min ( x ) ; return ( int ) Math . ceil ( ( max - min ) / h ) ; }
Returns the number of bins for a data based on a suggested bin width h .