calculate histogram from a list of values