code: public static double variance(int[] histogram, double mean, int counts , int N) {
  		double sum = 0.0;
  		for(int i=0;i<N;i++) {
  			double d = i - mean;
  			sum += (d*d) * histogram[i];
  		}
  
  		return sum / counts;
  	}
docs: Computes the variance of elements in the histogram
  
  @param histogram Histogram with N bins
  @param mean Histogram's mean.
  @param counts Sum of all bins in the histogram.
  @param N number of bins in the histogram.
  @return variance of values inside the histogram