added histograms and discrete sampling