optimized histogram estimation