final histogram script for large 0.5TB dataset