dynamic histograms

and reference impls