[SPARK-2862] histogram method fails on some choices of bucketCount

Sounds good. I will incorporate this change and retest.